Browse Source

Merged 'default' into branch 'iOS-improvements'

Alex Szpakowski 10 năm trước cách đây
mục cha
commit
bde54b7f34
54 tập tin đã thay đổi với 876 bổ sung357 xóa
  1. 1 0
      .hgignore
  2. 4 4
      INSTALL.txt
  3. 2 23
      README.txt
  4. 4 0
      VisualC/SDL/SDL_VS2008.vcproj
  5. 5 1
      VisualC/SDL/SDL_VS2010.vcxproj
  6. 5 1
      VisualC/SDL/SDL_VS2012.vcxproj
  7. 4 0
      VisualC/SDL/SDL_VS2013.vcxproj
  8. 4 0
      VisualC/SDLmain/SDLmain_VS2008.vcproj
  9. 167 163
      VisualC/SDLmain/SDLmain_VS2010.vcxproj
  10. 5 1
      VisualC/SDLmain/SDLmain_VS2012.vcxproj
  11. 4 0
      VisualC/SDLmain/SDLmain_VS2013.vcxproj
  12. 4 0
      VisualC/SDLtest/SDLtest_VS2008.vcproj
  13. 5 1
      VisualC/SDLtest/SDLtest_VS2010.vcxproj
  14. 5 1
      VisualC/SDLtest/SDLtest_VS2012.vcxproj
  15. 4 0
      VisualC/SDLtest/SDLtest_VS2013.vcxproj
  16. 1 2
      docs/README-android.md
  17. 2 2
      docs/README-cmake.md
  18. 2 1
      docs/README-directfb.md
  19. 0 1
      docs/README-dynapi.md
  20. 0 1
      docs/README-gesture.md
  21. 3 0
      docs/README-hg.md
  22. 3 0
      docs/README-ios.md
  23. 1 2
      docs/README-linux.md
  24. 1 2
      docs/README-macosx.md
  25. 1 2
      docs/README-nacl.md
  26. 3 2
      docs/README-pandora.md
  27. 3 0
      docs/README-platforms.md
  28. 2 0
      docs/README-porting.md
  29. 2 0
      docs/README-psp.md
  30. 1 2
      docs/README-raspberrypi.md
  31. 1 0
      docs/README-touch.md
  32. 2 0
      docs/README-wince.md
  33. 1 2
      docs/README-windows.md
  34. 1 2
      docs/README-winrt.md
  35. 62 0
      docs/README.md
  36. 14 10
      docs/doxyfile
  37. 0 35
      include/SDL.h
  38. 4 7
      include/SDL_assert.h
  39. 103 4
      include/SDL_audio.h
  40. 226 14
      src/audio/SDL_audio.c
  41. 27 0
      src/audio/SDL_sysaudio.h
  42. 3 3
      src/audio/xaudio2/SDL_xaudio2.c
  43. 4 4
      src/core/linux/SDL_ibus.c
  44. 3 0
      src/dynapi/SDL_dynapi_overrides.h
  45. 3 0
      src/dynapi/SDL_dynapi_procs.h
  46. 2 25
      src/main/windows/SDL_windows_main.c
  47. 3 0
      src/render/opengl/SDL_render_gl.c
  48. 1 1
      src/render/software/SDL_draw.h
  49. 29 38
      src/stdlib/SDL_stdlib.c
  50. 1 0
      src/video/SDL_sysvideo.h
  51. 6 0
      src/video/SDL_video.c
  52. 4 0
      test/Makefile.in
  53. 1 0
      test/README
  54. 127 0
      test/loopwavequeue.c

+ 1 - 0
.hgignore

@@ -76,6 +76,7 @@ test/Makefile
 test/SDL2.dll
 test/checkkeys
 test/loopwave
+test/loopwavequeue
 test/testatomic
 test/testaudioinfo
 test/testautomation

+ 4 - 4
INSTALL.txt

@@ -9,7 +9,7 @@ To compile and install SDL:
         * Run './configure; make; make install'
 
         Mac OS X with Xcode:
-        * Read README-macosx.txt
+        * Read docs/README-macosx.md
 
         Mac OS X from the command line:
         * Run './configure; make; make install'
@@ -18,13 +18,13 @@ To compile and install SDL:
         * Run './configure; make; make install'
 
         Android:
-        * Read README-android.txt
+        * Read docs/README-android.md
 
         iOS:
-        * Read README-ios.txt
+        * Read docs/README-ios.md
 
         Using Cmake:
-        * Read README-cmake.txt
+        * Read docs/README-cmake.md
 
     2.  Look at the example programs in ./test, and check out the online
         documentation at http://wiki.libsdl.org/

+ 2 - 23
README.txt

@@ -14,29 +14,8 @@ hardware via OpenGL and Direct3D. It is used by video playback software,
 emulators, and popular games including Valve's award winning catalog
 and many Humble Bundle games.
 
-SDL officially supports Windows, Mac OS X, Linux, iOS, and Android.
-Support for other platforms may be found in the source code.
-
-SDL is written in C, works natively with C++, and there are bindings 
-available for several other languages, including C# and Python.
-
-This library is distributed under the zlib license, which can be found
-in the file "COPYING.txt".
-
-The best way to learn how to use SDL is to check out the header files in
-the "include" subdirectory and the programs in the "test" subdirectory.
-The header files and test programs are well commented and always up to date.
-More documentation and FAQs are available online at:
-	http://wiki.libsdl.org/
-
-If you need help with the library, or just want to discuss SDL related
-issues, you can join the developers mailing list:
-	http://www.libsdl.org/mailing-list.php
-
-If you want to report bugs or contribute patches, please submit them to
-bugzilla:
-    http://bugzilla.libsdl.org/
+More extensive documentation is available in the docs directory, starting
+with README.md
 
 Enjoy!
 	Sam Lantinga				(slouken@libsdl.org)
-

+ 4 - 0
VisualC/SDL/SDL_VS2008.vcproj

@@ -61,6 +61,7 @@
 				Detect64BitPortabilityProblems="false"
 				DebugInformationFormat="4"
 				CompileAs="0"
+				OmitDefaultLibName="true"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -144,6 +145,7 @@
 				Detect64BitPortabilityProblems="false"
 				DebugInformationFormat="4"
 				CompileAs="0"
+				OmitDefaultLibName="true"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -232,6 +234,7 @@
 				Detect64BitPortabilityProblems="false"
 				DebugInformationFormat="3"
 				CompileAs="0"
+				OmitDefaultLibName="true"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -320,6 +323,7 @@
 				Detect64BitPortabilityProblems="false"
 				DebugInformationFormat="3"
 				CompileAs="0"
+				OmitDefaultLibName="true"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"

+ 5 - 1
VisualC/SDL/SDL_VS2010.vcxproj

@@ -94,6 +94,7 @@
       <CompileAs>Default</CompileAs>
       <ExceptionHandling>false</ExceptionHandling>
       <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <ResourceCompile>
       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -127,6 +128,7 @@
       <WarningLevel>Level3</WarningLevel>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <ResourceCompile>
       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -167,6 +169,7 @@
       <ExceptionHandling>false</ExceptionHandling>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
       <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <ResourceCompile>
       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -203,6 +206,7 @@
       <WarningLevel>Level3</WarningLevel>
       <ExceptionHandling>false</ExceptionHandling>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <ResourceCompile>
       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -510,4 +514,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>

+ 5 - 1
VisualC/SDL/SDL_VS2012.vcxproj

@@ -98,6 +98,7 @@
       <CompileAs>Default</CompileAs>
       <ExceptionHandling>false</ExceptionHandling>
       <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <ResourceCompile>
       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -131,6 +132,7 @@
       <WarningLevel>Level3</WarningLevel>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <ResourceCompile>
       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -171,6 +173,7 @@
       <ExceptionHandling>false</ExceptionHandling>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
       <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <ResourceCompile>
       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -207,6 +210,7 @@
       <WarningLevel>Level3</WarningLevel>
       <ExceptionHandling>false</ExceptionHandling>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <ResourceCompile>
       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -514,4 +518,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>

+ 4 - 0
VisualC/SDL/SDL_VS2013.vcxproj

@@ -98,6 +98,7 @@
       <CompileAs>Default</CompileAs>
       <ExceptionHandling>false</ExceptionHandling>
       <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <ResourceCompile>
       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -131,6 +132,7 @@
       <WarningLevel>Level3</WarningLevel>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <ResourceCompile>
       <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -171,6 +173,7 @@
       <ExceptionHandling>false</ExceptionHandling>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
       <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <ResourceCompile>
       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -207,6 +210,7 @@
       <WarningLevel>Level3</WarningLevel>
       <ExceptionHandling>false</ExceptionHandling>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <ResourceCompile>
       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>

+ 4 - 0
VisualC/SDLmain/SDLmain_VS2008.vcproj

@@ -56,6 +56,7 @@
 				SuppressStartupBanner="true"
 				DebugInformationFormat="1"
 				CompileAs="0"
+				OmitDefaultLibName="true"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -123,6 +124,7 @@
 				SuppressStartupBanner="true"
 				DebugInformationFormat="1"
 				CompileAs="0"
+				OmitDefaultLibName="true"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -316,6 +318,7 @@
 				SuppressStartupBanner="true"
 				DebugInformationFormat="1"
 				CompileAs="0"
+				OmitDefaultLibName="true"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -381,6 +384,7 @@
 				SuppressStartupBanner="true"
 				DebugInformationFormat="1"
 				CompileAs="0"
+				OmitDefaultLibName="true"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"

+ 167 - 163
VisualC/SDLmain/SDLmain_VS2010.vcxproj

@@ -1,164 +1,168 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup Label="ProjectConfigurations">
-    <ProjectConfiguration Include="Debug|Win32">
-      <Configuration>Debug</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Debug|x64">
-      <Configuration>Debug</Configuration>
-      <Platform>x64</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|x64">
-      <Configuration>Release</Configuration>
-      <Platform>x64</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <ProjectName>SDL2main</ProjectName>
-    <ProjectGuid>{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}</ProjectGuid>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>StaticLibrary</ConfigurationType>
-    <UseOfMfc>false</UseOfMfc>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>StaticLibrary</ConfigurationType>
-    <UseOfMfc>false</UseOfMfc>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
-    <ConfigurationType>StaticLibrary</ConfigurationType>
-    <UseOfMfc>false</UseOfMfc>
-    <CharacterSet>MultiByte</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
-    <ConfigurationType>StaticLibrary</ConfigurationType>
-    <UseOfMfc>false</UseOfMfc>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings">
-  </ImportGroup>
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
-  </ImportGroup>
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
-  </ImportGroup>
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
-  </ImportGroup>
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <PropertyGroup>
-    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
-    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\$(Platform)\$(Configuration)\</OutDir>
-    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</IntDir>
-    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)\$(Platform)\$(Configuration)\</OutDir>
-    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
-    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\$(Platform)\$(Configuration)\</OutDir>
-    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</IntDir>
-    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)\$(Platform)\$(Configuration)\</OutDir>
-    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
-  </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <PreBuildEvent />
-    <ClCompile>
-      <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
-      <AdditionalIncludeDirectories>..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <StringPooling>true</StringPooling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <WarningLevel>Level3</WarningLevel>
-      <SuppressStartupBanner>true</SuppressStartupBanner>
-      <CompileAs>Default</CompileAs>
-      <DebugInformationFormat>OldStyle</DebugInformationFormat>
-      <ExceptionHandling>false</ExceptionHandling>
-    </ClCompile>
-    <Lib>
-      <SuppressStartupBanner>true</SuppressStartupBanner>
-    </Lib>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
-    <Midl>
-      <TargetEnvironment>X64</TargetEnvironment>
-    </Midl>
-    <ClCompile>
-      <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
-      <AdditionalIncludeDirectories>..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <StringPooling>true</StringPooling>
-      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <WarningLevel>Level3</WarningLevel>
-      <SuppressStartupBanner>true</SuppressStartupBanner>
-      <CompileAs>Default</CompileAs>
-      <DebugInformationFormat>OldStyle</DebugInformationFormat>
-      <ExceptionHandling>false</ExceptionHandling>
-    </ClCompile>
-    <Lib>
-      <SuppressStartupBanner>true</SuppressStartupBanner>
-    </Lib>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <PreBuildEvent />
-    <ClCompile>
-      <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <WarningLevel>Level3</WarningLevel>
-      <SuppressStartupBanner>true</SuppressStartupBanner>
-      <DebugInformationFormat>OldStyle</DebugInformationFormat>
-      <CompileAs>Default</CompileAs>
-      <ExceptionHandling>false</ExceptionHandling>
-    </ClCompile>
-    <Lib>
-      <SuppressStartupBanner>true</SuppressStartupBanner>
-    </Lib>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
-    <Midl>
-      <TargetEnvironment>X64</TargetEnvironment>
-    </Midl>
-    <ClCompile>
-      <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <WarningLevel>Level3</WarningLevel>
-      <SuppressStartupBanner>true</SuppressStartupBanner>
-      <DebugInformationFormat>OldStyle</DebugInformationFormat>
-      <CompileAs>Default</CompileAs>
-      <ExceptionHandling>false</ExceptionHandling>
-    </ClCompile>
-    <Lib>
-      <SuppressStartupBanner>true</SuppressStartupBanner>
-    </Lib>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <ClCompile Include="..\..\src\main\windows\SDL_windows_main.c" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectName>SDL2main</ProjectName>
+    <ProjectGuid>{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}</ProjectGuid>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <UseOfMfc>false</UseOfMfc>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <UseOfMfc>false</UseOfMfc>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <UseOfMfc>false</UseOfMfc>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <UseOfMfc>false</UseOfMfc>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup>
+    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</IntDir>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</IntDir>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)\$(Platform)\$(Configuration)\</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <PreBuildEvent />
+    <ClCompile>
+      <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+      <AdditionalIncludeDirectories>..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <StringPooling>true</StringPooling>
+      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+      <CompileAs>Default</CompileAs>
+      <DebugInformationFormat>OldStyle</DebugInformationFormat>
+      <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
+    </ClCompile>
+    <Lib>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+    </Lib>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <Midl>
+      <TargetEnvironment>X64</TargetEnvironment>
+    </Midl>
+    <ClCompile>
+      <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+      <AdditionalIncludeDirectories>..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <StringPooling>true</StringPooling>
+      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+      <CompileAs>Default</CompileAs>
+      <DebugInformationFormat>OldStyle</DebugInformationFormat>
+      <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
+    </ClCompile>
+    <Lib>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+    </Lib>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <PreBuildEvent />
+    <ClCompile>
+      <Optimization>Disabled</Optimization>
+      <AdditionalIncludeDirectories>..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+      <DebugInformationFormat>OldStyle</DebugInformationFormat>
+      <CompileAs>Default</CompileAs>
+      <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
+    </ClCompile>
+    <Lib>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+    </Lib>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <Midl>
+      <TargetEnvironment>X64</TargetEnvironment>
+    </Midl>
+    <ClCompile>
+      <Optimization>Disabled</Optimization>
+      <AdditionalIncludeDirectories>..\..\include;..\..\include\SDL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+      <DebugInformationFormat>OldStyle</DebugInformationFormat>
+      <CompileAs>Default</CompileAs>
+      <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
+    </ClCompile>
+    <Lib>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+    </Lib>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\src\main\windows\SDL_windows_main.c" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
 </Project>

+ 5 - 1
VisualC/SDLmain/SDLmain_VS2012.vcxproj

@@ -91,6 +91,7 @@
       <CompileAs>Default</CompileAs>
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>
@@ -114,6 +115,7 @@
       <CompileAs>Default</CompileAs>
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>
@@ -133,6 +135,7 @@
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <CompileAs>Default</CompileAs>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>
@@ -154,6 +157,7 @@
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <CompileAs>Default</CompileAs>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>
@@ -165,4 +169,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>

+ 4 - 0
VisualC/SDLmain/SDLmain_VS2013.vcxproj

@@ -91,6 +91,7 @@
       <CompileAs>Default</CompileAs>
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>
@@ -114,6 +115,7 @@
       <CompileAs>Default</CompileAs>
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>
@@ -133,6 +135,7 @@
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <CompileAs>Default</CompileAs>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>
@@ -154,6 +157,7 @@
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <CompileAs>Default</CompileAs>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>

+ 4 - 0
VisualC/SDLtest/SDLtest_VS2008.vcproj

@@ -56,6 +56,7 @@
 				SuppressStartupBanner="true"
 				DebugInformationFormat="1"
 				CompileAs="0"
+				OmitDefaultLibName="true"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -123,6 +124,7 @@
 				SuppressStartupBanner="true"
 				DebugInformationFormat="1"
 				CompileAs="0"
+				OmitDefaultLibName="true"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -316,6 +318,7 @@
 				SuppressStartupBanner="true"
 				DebugInformationFormat="1"
 				CompileAs="0"
+				OmitDefaultLibName="true"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -381,6 +384,7 @@
 				SuppressStartupBanner="true"
 				DebugInformationFormat="1"
 				CompileAs="0"
+				OmitDefaultLibName="true"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"

+ 5 - 1
VisualC/SDLtest/SDLtest_VS2010.vcxproj

@@ -87,6 +87,7 @@
       <CompileAs>Default</CompileAs>
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>
@@ -110,6 +111,7 @@
       <CompileAs>Default</CompileAs>
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>
@@ -129,6 +131,7 @@
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <CompileAs>Default</CompileAs>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>
@@ -150,6 +153,7 @@
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <CompileAs>Default</CompileAs>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>
@@ -189,4 +193,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>

+ 5 - 1
VisualC/SDLtest/SDLtest_VS2012.vcxproj

@@ -91,6 +91,7 @@
       <CompileAs>Default</CompileAs>
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>
@@ -114,6 +115,7 @@
       <CompileAs>Default</CompileAs>
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>
@@ -133,6 +135,7 @@
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <CompileAs>Default</CompileAs>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>
@@ -154,6 +157,7 @@
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <CompileAs>Default</CompileAs>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>
@@ -193,4 +197,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>

+ 4 - 0
VisualC/SDLtest/SDLtest_VS2013.vcxproj

@@ -91,6 +91,7 @@
       <CompileAs>Default</CompileAs>
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>
@@ -114,6 +115,7 @@
       <CompileAs>Default</CompileAs>
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>
@@ -133,6 +135,7 @@
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <CompileAs>Default</CompileAs>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>
@@ -154,6 +157,7 @@
       <DebugInformationFormat>OldStyle</DebugInformationFormat>
       <CompileAs>Default</CompileAs>
       <ExceptionHandling>false</ExceptionHandling>
+      <OmitDefaultLibName>true</OmitDefaultLibName>
     </ClCompile>
     <Lib>
       <SuppressStartupBanner>true</SuppressStartupBanner>

+ 1 - 2
README-android.txt → docs/README-android.md

@@ -1,5 +1,4 @@
-================================================================================
-Simple DirectMedia Layer for Android
+Android
 ================================================================================
 
 Requirements:

+ 2 - 2
README-cmake.txt → docs/README-cmake.md

@@ -1,6 +1,6 @@
+CMake
 ================================================================================
-CMake build system for SDL (www.cmake.org)
-================================================================================
+(www.cmake.org)
 
 SDL's build system was traditionally based on autotools. Over time, this
 approach has suffered from several issues across the different supported 

+ 2 - 1
README-directfb.txt → docs/README-directfb.md

@@ -1,4 +1,5 @@
-SDL on DirectFB
+DirectFB
+========
 
 Supports:
 

+ 0 - 1
README-dynapi.txt → docs/README-dynapi.md

@@ -1,4 +1,3 @@
-================================================================================
 Dynamic API
 ================================================================================
 Originally posted by Ryan at https://plus.google.com/103391075724026391227/posts/TB8UfnDYu4U

+ 0 - 1
README-gesture.txt → docs/README-gesture.md

@@ -1,4 +1,3 @@
-===========================================================================
 Dollar Gestures
 ===========================================================================
 SDL Provides an implementation of the $1 gesture recognition system. This allows for recording, saving, loading, and performing single stroke gestures.

+ 3 - 0
README-hg.txt → docs/README-hg.md

@@ -1,3 +1,6 @@
+Mercurial
+=========
+
 The latest development version of SDL is available via Mercurial.
 Mercurial allows you to get up-to-the-minute fixes and enhancements;
 as a developer works on a source tree, you can use "hg" to mirror that

+ 3 - 0
README-ios.txt → docs/README-ios.md

@@ -1,3 +1,6 @@
+iOS
+======
+
 ==============================================================================
 Building the Simple DirectMedia Layer for iPhone OS 5.1
 ==============================================================================

+ 1 - 2
README-linux.txt → docs/README-linux.md

@@ -1,5 +1,4 @@
-================================================================================
-Simple DirectMedia Layer for Linux
+Linux
 ================================================================================
 
 By default SDL will only link against glibc, the rest of the features will be

+ 1 - 2
README-macosx.txt → docs/README-macosx.md

@@ -1,5 +1,4 @@
-==============================================================================
-Using the Simple DirectMedia Layer with Mac OS X
+Mac OS X
 ==============================================================================
 
 These instructions are for people using Apple's Mac OS X (pronounced

+ 1 - 2
README-nacl.txt → docs/README-nacl.md

@@ -1,5 +1,4 @@
-================================================================================
-Simple DirectMedia Layer for Native Client
+Native Client
 ================================================================================
 
 Requirements: 

+ 3 - 2
README-pandora.txt → docs/README-pandora.md

@@ -1,6 +1,7 @@
-SDL 2.0 with open pandora console support ( http://openpandora.org/ )
+Pandora 
 =====================================================================
-
+
+( http://openpandora.org/ )
 - A pandora specific video driver was written to allow SDL 2.0 with OpenGL ES
 support to work on the pandora under the framebuffer. This driver do not have
 input support for now, so if you use it you will have to add your own control code.

+ 3 - 0
README-platforms.txt → docs/README-platforms.md

@@ -1,3 +1,6 @@
+Platforms
+=========
+
 
 This is a list of the platforms SDL supports, and who maintains them.
 

+ 2 - 0
README-porting.txt → docs/README-porting.md

@@ -1,3 +1,5 @@
+Porting
+=======
 
 * Porting To A New Platform
 

+ 2 - 0
README-psp.txt → docs/README-psp.md

@@ -1,3 +1,5 @@
+PSP
+======
 SDL port for the Sony PSP contributed by 
    Captian Lex 
 

+ 1 - 2
README-raspberrypi.txt → docs/README-raspberrypi.md

@@ -1,5 +1,4 @@
-================================================================================
-SDL2 for Raspberry Pi
+Raspberry Pi
 ================================================================================
 
 Requirements:

+ 1 - 0
README-touch.txt → docs/README-touch.md

@@ -1,3 +1,4 @@
+Touch
 ===========================================================================
 System Specific Notes
 ===========================================================================

+ 2 - 0
README-wince.txt → docs/README-wince.md

@@ -1,3 +1,5 @@
+WinCE
+=====
 
 Windows CE is no longer supported by SDL.
 

+ 1 - 2
README-windows.txt → docs/README-windows.md

@@ -1,5 +1,4 @@
-================================================================================
-Simple DirectMedia Layer for Windows
+Windows
 ================================================================================
 
 ================================================================================

+ 1 - 2
README-winrt.txt → docs/README-winrt.md

@@ -1,5 +1,4 @@
-================================================================================
-Simple DirectMedia Layer for WinRT
+WinRT
 ================================================================================
 
 SDL/WinRT layer allows SDL2-based applications to run on many of Microsoft's

+ 62 - 0
docs/README.md

@@ -0,0 +1,62 @@
+Simple DirectMedia Layer {#mainpage}
+========================
+
+                                  (SDL)
+
+                                Version 2.0
+
+---
+http://www.libsdl.org/
+
+Simple DirectMedia Layer is a cross-platform development library designed
+to provide low level access to audio, keyboard, mouse, joystick, and graphics
+hardware via OpenGL and Direct3D. It is used by video playback software,
+emulators, and popular games including Valve's award winning catalog
+and many Humble Bundle games. 42
+
+SDL officially supports Windows, Mac OS X, Linux, iOS, and Android.
+Support for other platforms may be found in the source code.
+
+SDL is written in C, works natively with C++, and there are bindings 
+available for several other languages, including C# and Python.
+
+This library is distributed under the zlib license, which can be found
+in the file "COPYING.txt".
+
+The best way to learn how to use SDL is to check out the header files in
+the "include" subdirectory and the programs in the "test" subdirectory.
+The header files and test programs are well commented and always up to date.
+
+More documentation and FAQs are available online at [the wiki](http://wiki.libsdl.org/)
+
+- [Android](README-android.md)
+- [CMake](README-cmake.md)
+- [DirectFB](README-directfb.md)
+- [DynAPI](README-dynapi.md)
+- [Gesture](README-gesture.md)
+- [Mercurial](README-hg.md)
+- [iOS](README-ios.md)
+- [Linux](README-linux.md)
+- [OS X](README-macosx.md)
+- [Native Client](README-nacl.md)
+- [Pandora](README-pandora.md)
+- [Supported Platforms](README-platforms.md)
+- [Porting information](README-porting.md)
+- [PSP](README-psp.md)
+- [Raspberry Pi](README-raspberrypi.md)
+- [Touch](README-touch.md)
+- [WinCE](README-wince.md)
+- [Windows](README-windows.md)
+- [WinRT](README-winrt.md)
+
+If you need help with the library, or just want to discuss SDL related
+issues, you can join the [developers mailing list](http://www.libsdl.org/mailing-list.php)
+
+If you want to report bugs or contribute patches, please submit them to
+[bugzilla](http://bugzilla.libsdl.org/)
+
+Enjoy!
+
+
+Sam Lantinga <mailto:slouken@libsdl.org>
+

+ 14 - 10
include/doxyfile → docs/doxyfile

@@ -38,7 +38,7 @@ PROJECT_NUMBER         = 2.0.0
 # If a relative path is entered, it will be relative to the location 
 # where doxygen was started. If left blank the current directory will be used.
 
-OUTPUT_DIRECTORY       = .
+OUTPUT_DIRECTORY       = ./output
 
 # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 
 # 4096 sub-directories (in 2 levels) under the output directory of each output 
@@ -569,7 +569,7 @@ WARN_LOGFILE           = ./doxygen_warn.txt
 # directories like "/usr/src/myproject". Separate the files or directories 
 # with spaces.
 
-INPUT                  = .
+INPUT                  = . ../include
 
 # This tag can be used to specify the character encoding of the source files 
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 
@@ -618,7 +618,8 @@ FILE_PATTERNS          = *.c \
                          *.vhd \
                          *.vhdl \
                          *.h.in \
-                         *.h.default
+                         *.h.default \
+                         *.md
 
 # The RECURSIVE tag can be used to turn specify whether or not subdirectories 
 # should be searched for input files as well. Possible values are YES and NO. 
@@ -630,12 +631,15 @@ RECURSIVE              = YES
 # excluded from the INPUT source files. This way you can easily exclude a 
 # subdirectory from a directory tree whose root is specified with the INPUT tag.
 
-EXCLUDE                = ../doxy \
-                         ../test \
-                         ../Xcode \
-                         ../VisualC \
-                         ../VisualCE \
-                         ../Xcode-iOS
+EXCLUDE                = ../include/SDL_opengles2_gl2ext.h \
+                         ../include/SDL_opengles2_gl2platform.h \
+                         ../include/SDL_opengles2_khrplatform.h \
+                         ../include/SDL_opengl_glext.h \
+                         ../include/SDL_opengles2_gl2.h \
+                         ../include/SDL_opengles2.h \
+                         ../include/SDL_opengles.h \
+                         ../include/SDL_opengl.h \
+
 
 # The EXCLUDE_SYMLINKS tag can be used select whether or not files or 
 # directories that are symbolic links (a Unix filesystem feature) are excluded 
@@ -1271,7 +1275,7 @@ SEARCH_INCLUDES        = YES
 # contain include files that are not input files but should be processed by 
 # the preprocessor.
 
-INCLUDE_PATH           = 
+INCLUDE_PATH           =
 
 # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
 # patterns (like *.h and *.hpp) to filter out the header-files in the 

+ 0 - 35
include/SDL.h

@@ -25,41 +25,6 @@
  *  Main include header for the SDL library
  */
 
-/**
- *  \mainpage Simple DirectMedia Layer (SDL)
- *
- *  http://www.libsdl.org/
- *
- *  \section intro_sec Introduction
- *
- *  Simple DirectMedia Layer is a cross-platform development library designed
- *  to provide low level access to audio, keyboard, mouse, joystick, and
- *  graphics hardware via OpenGL and Direct3D. It is used by video playback
- *  software, emulators, and popular games including Valve's award winning
- *  catalog and many Humble Bundle games.
- *
- *  SDL officially supports Windows, Mac OS X, Linux, iOS, and Android.
- *  Support for other platforms may be found in the source code.
- *
- *  SDL is written in C, works natively with C++, and there are bindings 
- *  available for several other languages, including C# and Python.
- *
- *  This library is distributed under the zlib license, which can be found
- *  in the file "COPYING.txt".
- *
- *  The best way to learn how to use SDL is to check out the header files in
- *  the "include" subdirectory and the programs in the "test" subdirectory.
- *  The header files and test programs are well commented and always up to date.
- *  More documentation and FAQs are available online at:
- *      http://wiki.libsdl.org/
- *
- *  If you need help with the library, or just want to discuss SDL related
- *  issues, you can join the developers mailing list:
- *      http://www.libsdl.org/mailing-list.php
- *
- *  Enjoy!
- *      Sam Lantinga                (slouken@libsdl.org)
- */
 
 #ifndef _SDL_H
 #define _SDL_H

+ 4 - 7
include/SDL_assert.h

@@ -141,16 +141,13 @@ extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *,
 #define SDL_enabled_assert(condition) \
     do { \
         while ( !(condition) ) { \
-            static struct SDL_assert_data assert_data = { \
+            static struct SDL_assert_data sdl_assert_data = { \
                 0, 0, #condition, 0, 0, 0, 0 \
             }; \
-            const SDL_assert_state state = SDL_ReportAssertion(&assert_data, \
-                                                               SDL_FUNCTION, \
-                                                               SDL_FILE, \
-                                                               SDL_LINE); \
-            if (state == SDL_ASSERTION_RETRY) { \
+            const SDL_assert_state sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
+            if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
                 continue; /* go again. */ \
-            } else if (state == SDL_ASSERTION_BREAK) { \
+            } else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \
                 SDL_TriggerBreakpoint(); \
             } \
             break; /* not retrying. */ \

+ 103 - 4
include/SDL_audio.h

@@ -155,6 +155,9 @@ typedef Uint16 SDL_AudioFormat;
  *
  *  Once the callback returns, the buffer will no longer be valid.
  *  Stereo samples are stored in a LRLRLR ordering.
+ *
+ *  You can choose to avoid callbacks and use SDL_QueueAudio() instead, if
+ *  you like. Just open your audio device with a NULL callback.
  */
 typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream,
                                             int len);
@@ -171,8 +174,8 @@ typedef struct SDL_AudioSpec
     Uint16 samples;             /**< Audio buffer size in samples (power of 2) */
     Uint16 padding;             /**< Necessary for some compile environments */
     Uint32 size;                /**< Audio buffer size in bytes (calculated) */
-    SDL_AudioCallback callback;
-    void *userdata;
+    SDL_AudioCallback callback; /**< Callback that feeds the audio device (NULL to use SDL_QueueAudio()). */
+    void *userdata;             /**< Userdata passed to callback (ignored for NULL callbacks). */
 } SDL_AudioSpec;
 
 
@@ -273,9 +276,11 @@ extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void);
  *      to the audio buffer, and the length in bytes of the audio buffer.
  *      This function usually runs in a separate thread, and so you should
  *      protect data structures that it accesses by calling SDL_LockAudio()
- *      and SDL_UnlockAudio() in your code.
+ *      and SDL_UnlockAudio() in your code. Alternately, you may pass a NULL
+ *      pointer here, and call SDL_QueueAudio() with some frequency, to queue
+ *      more audio samples to be played.
  *    - \c desired->userdata is passed as the first parameter to your callback
- *      function.
+ *      function. If you passed a NULL callback, this value is ignored.
  *
  *  The audio device starts out playing silence when it's opened, and should
  *  be enabled for playing by calling \c SDL_PauseAudio(0) when you are ready
@@ -474,6 +479,100 @@ extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst,
                                                 SDL_AudioFormat format,
                                                 Uint32 len, int volume);
 
+/**
+ *  Queue more audio on non-callback devices.
+ *
+ *  SDL offers two ways to feed audio to the device: you can either supply a
+ *  callback that SDL triggers with some frequency to obtain more audio
+ *  (pull method), or you can supply no callback, and then SDL will expect
+ *  you to supply data at regular intervals (push method) with this function.
+ *
+ *  There are no limits on the amount of data you can queue, short of
+ *  exhaustion of address space. Queued data will drain to the device as
+ *  necessary without further intervention from you. If the device needs
+ *  audio but there is not enough queued, it will play silence to make up
+ *  the difference. This means you will have skips in your audio playback
+ *  if you aren't routinely queueing sufficient data.
+ *
+ *  This function copies the supplied data, so you are safe to free it when
+ *  the function returns. This function is thread-safe, but queueing to the
+ *  same device from two threads at once does not promise which buffer will
+ *  be queued first.
+ *
+ *  You may not queue audio on a device that is using an application-supplied
+ *  callback; doing so returns an error. You have to use the audio callback
+ *  or queue audio with this function, but not both.
+ *
+ *  You should not call SDL_LockAudio() on the device before queueing; SDL
+ *  handles locking internally for this function.
+ *
+ *  \param dev The device ID to which we will queue audio.
+ *  \param data The data to queue to the device for later playback.
+ *  \param len The number of bytes (not samples!) to which (data) points.
+ *  \return zero on success, -1 on error.
+ *
+ *  \sa SDL_GetQueuedAudioSize
+ *  \sa SDL_ClearQueuedAudio
+ */
+extern DECLSPEC int SDLCALL SDL_QueueAudio(SDL_AudioDeviceID dev, const void *data, Uint32 len);
+
+/**
+ *  Get the number of bytes of still-queued audio.
+ *
+ *  This is the number of bytes that have been queued for playback with
+ *  SDL_QueueAudio(), but have not yet been sent to the hardware.
+ *
+ *  Once we've sent it to the hardware, this function can not decide the exact
+ *  byte boundary of what has been played. It's possible that we just gave the
+ *  hardware several kilobytes right before you called this function, but it
+ *  hasn't played any of it yet, or maybe half of it, etc.
+ *
+ *  You may not queue audio on a device that is using an application-supplied
+ *  callback; calling this function on such a device always returns 0.
+ *  You have to use the audio callback or queue audio with SDL_QueueAudio(),
+ *  but not both.
+ *
+ *  You should not call SDL_LockAudio() on the device before querying; SDL
+ *  handles locking internally for this function.
+ *
+ *  \param dev The device ID of which we will query queued audio size.
+ *  \return Number of bytes (not samples!) of queued audio.
+ *
+ *  \sa SDL_QueueAudio
+ *  \sa SDL_ClearQueuedAudio
+ */
+extern DECLSPEC Uint32 SDLCALL SDL_GetQueuedAudioSize(SDL_AudioDeviceID dev);
+
+/**
+ *  Drop any queued audio data waiting to be sent to the hardware.
+ *
+ *  Immediately after this call, SDL_GetQueuedAudioSize() will return 0 and
+ *  the hardware will start playing silence if more audio isn't queued.
+ *
+ *  This will not prevent playback of queued audio that's already been sent
+ *  to the hardware, as we can not undo that, so expect there to be some
+ *  fraction of a second of audio that might still be heard. This can be
+ *  useful if you want to, say, drop any pending music during a level change
+ *  in your game.
+ *
+ *  You may not queue audio on a device that is using an application-supplied
+ *  callback; calling this function on such a device is always a no-op.
+ *  You have to use the audio callback or queue audio with SDL_QueueAudio(),
+ *  but not both.
+ *
+ *  You should not call SDL_LockAudio() on the device before clearing the
+ *  queue; SDL handles locking internally for this function.
+ *
+ *  This function always succeeds and thus returns void.
+ *
+ *  \param dev The device ID of which to clear the audio queue.
+ *
+ *  \sa SDL_QueueAudio
+ *  \sa SDL_GetQueuedAudioSize
+ */
+extern DECLSPEC void SDLCALL SDL_ClearQueuedAudio(SDL_AudioDeviceID dev);
+
+
 /**
  *  \name Audio lock functions
  *

+ 226 - 14
src/audio/SDL_audio.c

@@ -178,6 +178,12 @@ SDL_AudioPlayDevice_Default(_THIS)
 {                               /* no-op. */
 }
 
+static int
+SDL_AudioGetPendingBytes_Default(_THIS)
+{
+    return 0;
+}
+
 static Uint8 *
 SDL_AudioGetDeviceBuf_Default(_THIS)
 {
@@ -205,22 +211,34 @@ SDL_AudioOpenDevice_Default(_THIS, const char *devname, int iscapture)
     return -1;
 }
 
+static SDL_INLINE SDL_bool
+is_in_audio_device_thread(SDL_AudioDevice * device)
+{
+    /* The device thread locks the same mutex, but not through the public API.
+       This check is in case the application, in the audio callback,
+       tries to lock the thread that we've already locked from the
+       device thread...just in case we only have non-recursive mutexes. */
+    if (device->thread && (SDL_ThreadID() == device->threadid)) {
+        return SDL_TRUE;
+    }
+
+    return SDL_FALSE;
+}
+
 static void
 SDL_AudioLockDevice_Default(SDL_AudioDevice * device)
 {
-    if (device->thread && (SDL_ThreadID() == device->threadid)) {
-        return;
+    if (!is_in_audio_device_thread(device)) {
+        SDL_LockMutex(device->mixer_lock);
     }
-    SDL_LockMutex(device->mixer_lock);
 }
 
 static void
 SDL_AudioUnlockDevice_Default(SDL_AudioDevice * device)
 {
-    if (device->thread && (SDL_ThreadID() == device->threadid)) {
-        return;
+    if (!is_in_audio_device_thread(device)) {
+        SDL_UnlockMutex(device->mixer_lock);
     }
-    SDL_UnlockMutex(device->mixer_lock);
 }
 
 
@@ -241,6 +259,7 @@ finalize_audio_entry_points(void)
     FILL_STUB(ThreadInit);
     FILL_STUB(WaitDevice);
     FILL_STUB(PlayDevice);
+    FILL_STUB(GetPendingBytes);
     FILL_STUB(GetDeviceBuf);
     FILL_STUB(WaitDone);
     FILL_STUB(CloseDevice);
@@ -312,6 +331,181 @@ SDL_StreamDeinit(SDL_AudioStreamer * stream)
 }
 #endif
 
+
+/* buffer queueing support... */
+
+/* this expects that you managed thread safety elsewhere. */
+static void
+free_audio_queue(SDL_AudioBufferQueue *buffer)
+{
+    while (buffer) {
+        SDL_AudioBufferQueue *next = buffer->next;
+        SDL_free(buffer);
+        buffer = next;
+    }
+}
+
+static void SDLCALL
+SDL_BufferQueueDrainCallback(void *userdata, Uint8 *stream, int _len)
+{
+    /* this function always holds the mixer lock before being called. */
+    Uint32 len = (Uint32) _len;
+    SDL_AudioDevice *device = (SDL_AudioDevice *) userdata;
+    SDL_AudioBufferQueue *buffer;
+
+    SDL_assert(device != NULL);  /* this shouldn't ever happen, right?! */
+    SDL_assert(_len >= 0);  /* this shouldn't ever happen, right?! */
+
+    while ((len > 0) && ((buffer = device->buffer_queue_head) != NULL)) {
+        const Uint32 avail = buffer->datalen - buffer->startpos;
+        const Uint32 cpy = SDL_min(len, avail);
+        SDL_assert(device->queued_bytes >= avail);
+
+        SDL_memcpy(stream, buffer->data + buffer->startpos, cpy);
+        buffer->startpos += cpy;
+        stream += cpy;
+        device->queued_bytes -= cpy;
+        len -= cpy;
+
+        if (buffer->startpos == buffer->datalen) {  /* packet is done, put it in the pool. */
+            device->buffer_queue_head = buffer->next;
+            SDL_assert((buffer->next != NULL) || (buffer == device->buffer_queue_tail));
+            buffer->next = device->buffer_queue_pool;
+            device->buffer_queue_pool = buffer;
+        }
+    }
+
+    SDL_assert((device->buffer_queue_head != NULL) == (device->queued_bytes != 0));
+
+    if (len > 0) {  /* fill any remaining space in the stream with silence. */
+        SDL_assert(device->buffer_queue_head == NULL);
+        SDL_memset(stream, device->spec.silence, len);
+    }
+
+    if (device->buffer_queue_head == NULL) {
+        device->buffer_queue_tail = NULL;  /* in case we drained the queue entirely. */
+    }
+}
+
+int
+SDL_QueueAudio(SDL_AudioDeviceID devid, const void *_data, Uint32 len)
+{
+    SDL_AudioDevice *device = get_audio_device(devid);
+    const Uint8 *data = (const Uint8 *) _data;
+    SDL_AudioBufferQueue *orighead;
+    SDL_AudioBufferQueue *origtail;
+    Uint32 origlen;
+    Uint32 datalen;
+
+    if (!device) {
+        return -1;  /* get_audio_device() will have set the error state */
+    }
+
+    if (device->spec.callback != SDL_BufferQueueDrainCallback) {
+        return SDL_SetError("Audio device has a callback, queueing not allowed");
+    }
+
+    current_audio.impl.LockDevice(device);
+
+    orighead = device->buffer_queue_head;
+    origtail = device->buffer_queue_tail;
+    origlen = origtail ? origtail->datalen : 0;
+
+    while (len > 0) {
+        SDL_AudioBufferQueue *packet = device->buffer_queue_tail;
+        SDL_assert(!packet || (packet->datalen <= SDL_AUDIOBUFFERQUEUE_PACKETLEN));
+        if (!packet || (packet->datalen >= SDL_AUDIOBUFFERQUEUE_PACKETLEN)) {
+            /* tail packet missing or completely full; we need a new packet. */
+            packet = device->buffer_queue_pool;
+            if (packet != NULL) {
+                /* we have one available in the pool. */
+                device->buffer_queue_pool = packet->next;
+            } else {
+                /* Have to allocate a new one! */
+                packet = (SDL_AudioBufferQueue *) SDL_malloc(sizeof (SDL_AudioBufferQueue));
+                if (packet == NULL) {
+                    /* uhoh, reset so we've queued nothing new, free what we can. */
+                    if (!origtail) {
+                        packet = device->buffer_queue_head;  /* whole queue. */
+                    } else {
+                        packet = origtail->next;  /* what we added to existing queue. */
+                        origtail->next = NULL;
+                        origtail->datalen = origlen;
+                    }
+                    device->buffer_queue_head = orighead;
+                    device->buffer_queue_tail = origtail;
+                    device->buffer_queue_pool = NULL;
+
+                    current_audio.impl.UnlockDevice(device);
+
+                    free_audio_queue(packet);  /* give back what we can. */
+
+                    return SDL_OutOfMemory();
+                }
+            }
+            packet->datalen = 0;
+            packet->startpos = 0;
+            packet->next = NULL;
+
+            SDL_assert((device->buffer_queue_head != NULL) == (device->queued_bytes != 0));
+            if (device->buffer_queue_tail == NULL) {
+                device->buffer_queue_head = packet;
+            } else {
+                device->buffer_queue_tail->next = packet;
+            }
+            device->buffer_queue_tail = packet;
+        }
+
+        datalen = SDL_min(len, SDL_AUDIOBUFFERQUEUE_PACKETLEN - packet->datalen);
+        SDL_memcpy(packet->data + packet->datalen, data, datalen);
+        data += datalen;
+        len -= datalen;
+        packet->datalen += datalen;
+        device->queued_bytes += datalen;
+    }
+
+    current_audio.impl.UnlockDevice(device);
+
+    return 0;
+}
+
+Uint32
+SDL_GetQueuedAudioSize(SDL_AudioDeviceID devid)
+{
+    Uint32 retval = 0;
+    SDL_AudioDevice *device = get_audio_device(devid);
+
+    /* Nothing to do unless we're set up for queueing. */
+    if (device && (device->spec.callback == SDL_BufferQueueDrainCallback)) {
+        current_audio.impl.LockDevice(device);
+        retval = device->queued_bytes + current_audio.impl.GetPendingBytes(device);
+        current_audio.impl.UnlockDevice(device);
+    }
+
+    return retval;
+}
+
+void
+SDL_ClearQueuedAudio(SDL_AudioDeviceID devid)
+{
+    SDL_AudioDevice *device = get_audio_device(devid);
+    SDL_AudioBufferQueue *buffer = NULL;
+    if (!device) {
+        return;  /* nothing to do. */
+    }
+
+    /* Blank out the device and release the mutex. Free it afterwards. */
+    current_audio.impl.LockDevice(device);
+    buffer = device->buffer_queue_head;
+    device->buffer_queue_tail = NULL;
+    device->buffer_queue_head = NULL;
+    device->queued_bytes = 0;
+    current_audio.impl.UnlockDevice(device);
+
+    free_audio_queue(buffer);
+}
+
+
 #if defined(__ANDROID__)
 #include <android/log.h>
 #endif
@@ -788,6 +982,10 @@ close_audio_device(SDL_AudioDevice * device)
         current_audio.impl.CloseDevice(device);
         device->opened = 0;
     }
+
+    free_audio_queue(device->buffer_queue_head);
+    free_audio_queue(device->buffer_queue_pool);
+
     SDL_FreeAudioMem(device);
 }
 
@@ -802,11 +1000,6 @@ prepare_audiospec(const SDL_AudioSpec * orig, SDL_AudioSpec * prepared)
 {
     SDL_memcpy(prepared, orig, sizeof(SDL_AudioSpec));
 
-    if (orig->callback == NULL) {
-        SDL_SetError("SDL_OpenAudio() passed a NULL callback");
-        return 0;
-    }
-
     if (orig->freq == 0) {
         const char *env = SDL_getenv("SDL_AUDIO_FREQUENCY");
         if ((!env) || ((prepared->freq = SDL_atoi(env)) == 0)) {
@@ -859,7 +1052,6 @@ prepare_audiospec(const SDL_AudioSpec * orig, SDL_AudioSpec * prepared)
     return 1;
 }
 
-
 static SDL_AudioDeviceID
 open_audio_device(const char *devname, int iscapture,
                   const SDL_AudioSpec * desired, SDL_AudioSpec * obtained,
@@ -938,7 +1130,7 @@ open_audio_device(const char *devname, int iscapture,
         SDL_OutOfMemory();
         return 0;
     }
-    SDL_memset(device, '\0', sizeof(SDL_AudioDevice));
+    SDL_zerop(device);
     device->spec = *obtained;
     device->enabled = 1;
     device->paused = 1;
@@ -956,8 +1148,9 @@ open_audio_device(const char *devname, int iscapture,
 
     /* force a device detection if we haven't done one yet. */
     if ( ((iscapture) && (current_audio.inputDevices == NULL)) ||
-         ((!iscapture) && (current_audio.outputDevices == NULL)) )
+         ((!iscapture) && (current_audio.outputDevices == NULL)) ) {
         SDL_GetNumAudioDevices(iscapture);
+    }
 
     if (current_audio.impl.OpenDevice(device, devname, iscapture) < 0) {
         close_audio_device(device);
@@ -1031,6 +1224,25 @@ open_audio_device(const char *devname, int iscapture,
         }
     }
 
+    if (device->spec.callback == NULL) {  /* use buffer queueing? */
+        /* pool a few packets to start. Enough for two callbacks. */
+        const int packetlen = SDL_AUDIOBUFFERQUEUE_PACKETLEN;
+        const int wantbytes = ((device->convert.needed) ? device->convert.len : device->spec.size) * 2;
+        const int wantpackets = (wantbytes / packetlen) + ((wantbytes % packetlen) ? packetlen : 0);
+        for (i = 0; i < wantpackets; i++) {
+            SDL_AudioBufferQueue *packet = (SDL_AudioBufferQueue *) SDL_malloc(sizeof (SDL_AudioBufferQueue));
+            if (packet) { /* don't care if this fails, we'll deal later. */
+                packet->datalen = 0;
+                packet->startpos = 0;
+                packet->next = device->buffer_queue_pool;
+                device->buffer_queue_pool = packet;
+            }
+        }
+
+        device->spec.callback = SDL_BufferQueueDrainCallback;
+        device->spec.userdata = device;
+    }
+
     /* Find an available device ID and store the structure... */
     for (id = min_id - 1; id < SDL_arraysize(open_devices); id++) {
         if (open_devices[id] == NULL) {

+ 27 - 0
src/audio/SDL_sysaudio.h

@@ -33,6 +33,26 @@ typedef struct SDL_AudioDevice SDL_AudioDevice;
 /* Used by audio targets during DetectDevices() */
 typedef void (*SDL_AddAudioDevice)(const char *name);
 
+/* This is the size of a packet when using SDL_QueueAudio(). We allocate
+   these as necessary and pool them, under the assumption that we'll
+   eventually end up with a handful that keep recycling, meeting whatever
+   the app needs. We keep packing data tightly as more arrives to avoid
+   wasting space, and if we get a giant block of data, we'll split them
+   into multiple packets behind the scenes. My expectation is that most
+   apps will have 2-3 of these in the pool. 8k should cover most needs, but
+   if this is crippling for some embedded system, we can #ifdef this.
+   The system preallocates enough packets for 2 callbacks' worth of data. */
+#define SDL_AUDIOBUFFERQUEUE_PACKETLEN (8 * 1024)
+
+/* Used by apps that queue audio instead of using the callback. */
+typedef struct SDL_AudioBufferQueue
+{
+    Uint8 data[SDL_AUDIOBUFFERQUEUE_PACKETLEN];  /* packet data. */
+    Uint32 datalen;  /* bytes currently in use in this packet. */
+    Uint32 startpos;  /* bytes currently consumed in this packet. */
+    struct SDL_AudioBufferQueue *next;  /* next item in linked list. */
+} SDL_AudioBufferQueue;
+
 typedef struct SDL_AudioDriverImpl
 {
     void (*DetectDevices) (int iscapture, SDL_AddAudioDevice addfn);
@@ -40,6 +60,7 @@ typedef struct SDL_AudioDriverImpl
     void (*ThreadInit) (_THIS); /* Called by audio thread at start */
     void (*WaitDevice) (_THIS);
     void (*PlayDevice) (_THIS);
+    int (*GetPendingBytes) (_THIS);
     Uint8 *(*GetDeviceBuf) (_THIS);
     void (*WaitDone) (_THIS);
     void (*CloseDevice) (_THIS);
@@ -119,6 +140,12 @@ struct SDL_AudioDevice
     SDL_Thread *thread;
     SDL_threadID threadid;
 
+    /* Queued buffers (if app not using callback). */
+    SDL_AudioBufferQueue *buffer_queue_head; /* device fed from here. */
+    SDL_AudioBufferQueue *buffer_queue_tail; /* queue fills to here. */
+    SDL_AudioBufferQueue *buffer_queue_pool; /* these are unused packets. */
+    Uint32 queued_bytes;  /* number of bytes of audio data in the queue. */
+
     /* * * */
     /* Data private to this driver */
     struct SDL_PrivateAudioData *hidden;

+ 3 - 3
src/audio/xaudio2/SDL_xaudio2.c

@@ -58,7 +58,7 @@
 /* The configure script already did any necessary checking */
 #  define SDL_XAUDIO2_HAS_SDK 1
 #elif defined(__WINRT__)
-/* WinRT always has access to the .the XAudio 2 SDK */
+/* WinRT always has access to the the XAudio 2 SDK */
 #  define SDL_XAUDIO2_HAS_SDK
 #else
 /* XAudio2 exists as of the March 2008 DirectX SDK 
@@ -241,14 +241,14 @@ XAUDIO2_WaitDone(_THIS)
     SDL_assert(!this->enabled);  /* flag that stops playing. */
     IXAudio2SourceVoice_Discontinuity(source);
 #if SDL_XAUDIO2_WIN8
-    IXAudio2SourceVoice_GetState(source, &state, 0);
+    IXAudio2SourceVoice_GetState(source, &state, XAUDIO2_VOICE_NOSAMPLESPLAYED);
 #else
     IXAudio2SourceVoice_GetState(source, &state);
 #endif
     while (state.BuffersQueued > 0) {
         SDL_SemWait(this->hidden->semaphore);
 #if SDL_XAUDIO2_WIN8
-        IXAudio2SourceVoice_GetState(source, &state, 0);
+        IXAudio2SourceVoice_GetState(source, &state, XAUDIO2_VOICE_NOSAMPLESPLAYED);
 #else
         IXAudio2SourceVoice_GetState(source, &state);
 #endif

+ 4 - 4
src/core/linux/SDL_ibus.c

@@ -331,10 +331,10 @@ IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr)
     }
 
     if(result){
-        DBusMessage *msg = dbus->message_new_method_call(IBUS_SERVICE,
-                                                         input_ctx_path,
-                                                         IBUS_INPUT_INTERFACE,
-                                                         "SetCapabilities");
+        msg = dbus->message_new_method_call(IBUS_SERVICE,
+                                            input_ctx_path,
+                                            IBUS_INPUT_INTERFACE,
+                                            "SetCapabilities");
         if(msg){
             Uint32 caps = IBUS_CAP_FOCUS | IBUS_CAP_PREEDIT_TEXT;
             dbus->message_append_args(msg,

+ 3 - 0
src/dynapi/SDL_dynapi_overrides.h

@@ -588,3 +588,6 @@
 #define SDL_SetWindowHitTest SDL_SetWindowHitTest_REAL
 #define SDL_GetGlobalMouseState SDL_GetGlobalMouseState_REAL
 #define SDL_HasAVX2 SDL_HasAVX2_REAL
+#define SDL_QueueAudio SDL_QueueAudio_REAL
+#define SDL_GetQueuedAudioSize SDL_GetQueuedAudioSize_REAL
+#define SDL_ClearQueuedAudio SDL_ClearQueuedAudio_REAL

+ 3 - 0
src/dynapi/SDL_dynapi_procs.h

@@ -620,3 +620,6 @@ SDL_DYNAPI_PROC(int,SDL_CaptureMouse,(SDL_bool a),(a),return)
 SDL_DYNAPI_PROC(int,SDL_SetWindowHitTest,(SDL_Window *a, SDL_HitTest b, void *c),(a,b,c),return)
 SDL_DYNAPI_PROC(Uint32,SDL_GetGlobalMouseState,(int *a, int *b),(a,b),return)
 SDL_DYNAPI_PROC(SDL_bool,SDL_HasAVX2,(void),(),return)
+SDL_DYNAPI_PROC(int,SDL_QueueAudio,(SDL_AudioDeviceID a, const void *b, Uint32 c),(a,b,c),return)
+SDL_DYNAPI_PROC(Uint32,SDL_GetQueuedAudioSize,(SDL_AudioDeviceID a),(a),return)
+SDL_DYNAPI_PROC(void,SDL_ClearQueuedAudio,(SDL_AudioDeviceID a),(a),)

+ 2 - 25
src/main/windows/SDL_windows_main.c

@@ -10,9 +10,6 @@
 /* Include this so we define UNICODE properly */
 #include "../../core/windows/SDL_windows.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-
 /* Include the SDL main definition header */
 #include "SDL.h"
 #include "SDL_main.h"
@@ -103,23 +100,11 @@ ParseCommandLine(char *cmdline, char **argv)
     return (argc);
 }
 
-/* Show an error message */
-static void
-ShowError(const char *title, const char *message)
-{
-/* If USE_MESSAGEBOX is defined, you need to link with user32.lib */
-#ifdef USE_MESSAGEBOX
-    MessageBox(NULL, message, title, MB_ICONEXCLAMATION | MB_OK);
-#else
-    fprintf(stderr, "%s: %s\n", title, message);
-#endif
-}
-
 /* Pop up an out of memory message, returns to Windows */
 static BOOL
 OutOfMemory(void)
 {
-    ShowError("Fatal Error", "Out of memory - aborting");
+    SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal Error", "Out of memory - aborting", NULL);
     return FALSE;
 }
 
@@ -132,18 +117,10 @@ OutOfMemory(void)
 int
 console_main(int argc, char *argv[])
 {
-    int status;
-
     SDL_SetMainReady();
 
     /* Run the application main() code */
-    status = SDL_main(argc, argv);
-
-    /* Exit cleanly, calling atexit() functions */
-    exit(status);
-
-    /* Hush little compiler, don't you cry... */
-    return 0;
+    return SDL_main(argc, argv);
 }
 
 /* This is where execution begins [windowed apps] */

+ 3 - 0
src/render/opengl/SDL_render_gl.c

@@ -688,6 +688,9 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
     GL_CheckError("", renderer);
     renderdata->glGenTextures(1, &data->texture);
     if (GL_CheckError("glGenTexures()", renderer) < 0) {
+        if (data->pixels) {
+            SDL_free(data->pixels);
+        }
         SDL_free(data);
         return -1;
     }

+ 1 - 1
src/render/software/SDL_draw.h

@@ -51,7 +51,7 @@ do { \
 
 #define DRAW_SETPIXEL_BLEND(getpixel, setpixel) \
 do { \
-    unsigned sr, sg, sb, sa; \
+    unsigned sr, sg, sb, sa = 0xFF; \
     getpixel; \
     sr = DRAW_MUL(inva, sr) + r; \
     sg = DRAW_MUL(inva, sg) + g; \

+ 29 - 38
src/stdlib/SDL_stdlib.c

@@ -370,44 +370,35 @@ _ftol2_sse()
     _ftol();
 }
 
-/* 64-bit math operators for 32-bit systems */
-void
-__declspec(naked)
-_allmul()
-{
-    /* *INDENT-OFF* */
-    __asm {
-        push        ebp
-        mov         ebp,esp
-        push        edi
-        push        esi
-        push        ebx
-        sub         esp,0Ch
-        mov         eax,dword ptr [ebp+10h]
-        mov         edi,dword ptr [ebp+8]
-        mov         ebx,eax
-        mov         esi,eax
-        sar         esi,1Fh
-        mov         eax,dword ptr [ebp+8]
-        mul         ebx
-        imul        edi,esi
-        mov         ecx,edx
-        mov         dword ptr [ebp-18h],eax
-        mov         edx,dword ptr [ebp+0Ch]
-        add         ecx,edi
-        imul        ebx,edx
-        mov         eax,dword ptr [ebp-18h]
-        lea         ebx,[ebx+ecx]
-        mov         dword ptr [ebp-14h],ebx
-        mov         edx,dword ptr [ebp-14h]
-        add         esp,0Ch
-        pop         ebx
-        pop         esi
-        pop         edi
-        pop         ebp
-        ret         10h
-    }
-    /* *INDENT-ON* */
+/* 64-bit math operators for 32-bit systems */
+void
+__declspec(naked)
+_allmul()
+{
+    /* *INDENT-OFF* */
+    __asm {
+        mov         eax, dword ptr[esp+8]
+        mov         ecx, dword ptr[esp+10h]
+        or          ecx, eax
+        mov         ecx, dword ptr[esp+0Ch]
+        jne         hard
+        mov         eax, dword ptr[esp+4]
+        mul         ecx
+        ret         10h
+hard:
+        push        ebx
+        mul         ecx
+        mov         ebx, eax
+        mov         eax, dword ptr[esp+8]
+        mul         dword ptr[esp+14h]
+        add         ebx, eax
+        mov         eax, dword ptr[esp+8]
+        mul         ecx
+        add         edx, ebx
+        pop         ebx
+        ret         10h
+    }
+    /* *INDENT-ON* */
 }
 
 void

+ 1 - 0
src/video/SDL_sysvideo.h

@@ -93,6 +93,7 @@ struct SDL_Window
     SDL_Surface *surface;
     SDL_bool surface_valid;
 
+    SDL_bool is_hiding;
     SDL_bool is_destroying;
 
     SDL_WindowShaper *shaper;

+ 6 - 0
src/video/SDL_video.c

@@ -1105,6 +1105,10 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
 
     CHECK_WINDOW_MAGIC(window,);
 
+    /* if we are in the process of hiding don't go back to fullscreen */
+    if ( window->is_hiding && fullscreen )
+        return;
+    
 #ifdef __MACOSX__
     if (Cocoa_SetWindowFullscreenSpace(window, fullscreen)) {
         window->last_fullscreen_flags = window->flags;
@@ -1833,11 +1837,13 @@ SDL_HideWindow(SDL_Window * window)
         return;
     }
 
+	window->is_hiding = SDL_TRUE;
     SDL_UpdateFullscreenMode(window, SDL_FALSE);
 
     if (_this->HideWindow) {
         _this->HideWindow(_this, window);
     }
+	window->is_hiding = SDL_FALSE;
     SDL_SendWindowEvent(window, SDL_WINDOWEVENT_HIDDEN, 0, 0);
 }
 

+ 4 - 0
test/Makefile.in

@@ -10,6 +10,7 @@ LIBS	= @LIBS@
 TARGETS = \
 	checkkeys$(EXE) \
 	loopwave$(EXE) \
+	loopwavequeue$(EXE) \
 	testatomic$(EXE) \
 	testaudioinfo$(EXE) \
 	testautomation$(EXE) \
@@ -71,6 +72,9 @@ checkkeys$(EXE): $(srcdir)/checkkeys.c
 loopwave$(EXE): $(srcdir)/loopwave.c
 	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
 
+loopwavequeue$(EXE): $(srcdir)/loopwavequeue.c
+	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
+
 testresample$(EXE): $(srcdir)/testresample.c
 	$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
 

+ 1 - 0
test/README

@@ -3,6 +3,7 @@ These are test programs for the SDL library:
 
 	checkkeys	Watch the key events to check the keyboard
 	loopwave	Audio test -- loop playing a WAV file
+	loopwavequeue	Audio test -- loop playing a WAV file with SDL_QueueAudio
 	testaudioinfo	Lists audio device capabilities
 	testcdrom	Sample audio CD control program
 	testerror	Tests multi-threaded error handling

+ 127 - 0
test/loopwavequeue.c

@@ -0,0 +1,127 @@
+/*
+  Copyright (C) 1997-2014 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.
+*/
+
+/* Program to load a wave file and loop playing it using SDL sound queueing */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#if HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+
+#include "SDL.h"
+
+struct
+{
+    SDL_AudioSpec spec;
+    Uint8 *sound;               /* Pointer to wave data */
+    Uint32 soundlen;            /* Length of wave data */
+    int soundpos;               /* Current play position */
+} wave;
+
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void
+quit(int rc)
+{
+    SDL_Quit();
+    exit(rc);
+}
+
+static int done = 0;
+void
+poked(int sig)
+{
+    done = 1;
+}
+
+int
+main(int argc, char *argv[])
+{
+    int i;
+    char filename[4096];
+
+	/* Enable standard application logging */
+	SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
+    /* Load the SDL library */
+    if (SDL_Init(SDL_INIT_AUDIO) < 0) {
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        return (1);
+    }
+
+    if (argc > 1) {
+        SDL_strlcpy(filename, argv[1], sizeof(filename));
+    } else {
+        SDL_strlcpy(filename, "sample.wav", sizeof(filename));
+    }
+    /* Load the wave file into memory */
+    if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
+        quit(1);
+    }
+
+    wave.spec.callback = NULL;  /* we'll push audio. */
+
+#if HAVE_SIGNAL_H
+    /* Set the signals */
+#ifdef SIGHUP
+    signal(SIGHUP, poked);
+#endif
+    signal(SIGINT, poked);
+#ifdef SIGQUIT
+    signal(SIGQUIT, poked);
+#endif
+    signal(SIGTERM, poked);
+#endif /* HAVE_SIGNAL_H */
+
+    /* Initialize fillerup() variables */
+    if (SDL_OpenAudio(&wave.spec, NULL) < 0) {
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError());
+        SDL_FreeWAV(wave.sound);
+        quit(2);
+    }
+
+    /*static x[99999]; SDL_QueueAudio(1, x, sizeof (x));*/
+
+    /* Let the audio run */
+    SDL_PauseAudio(0);
+
+    /* Note that we stuff the entire audio buffer into the queue in one
+       shot. Most apps would want to feed it a little at a time, as it
+       plays, but we're going for simplicity here. */
+    
+    while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING))
+    {
+        /* The device from SDL_OpenAudio() is always device #1. */
+        const Uint32 queued = SDL_GetQueuedAudioSize(1);
+        SDL_Log("Device has %u bytes queued.\n", (unsigned int) queued);
+        if (queued <= 8192) {  /* time to requeue the whole thing? */
+            if (SDL_QueueAudio(1, wave.sound, wave.soundlen) == 0) {
+                SDL_Log("Device queued %u more bytes.\n", (unsigned int) wave.soundlen);
+            } else {
+                SDL_Log("Device FAILED to queue %u more bytes: %s\n", (unsigned int) wave.soundlen, SDL_GetError());
+            }
+        }
+
+        SDL_Delay(100);  /* let it play for awhile. */
+    }
+
+    /* Clean up on signal */
+    SDL_CloseAudio();
+    SDL_FreeWAV(wave.sound);
+    SDL_Quit();
+    return 0;
+}
+
+/* vi: set ts=4 sw=4 expandtab: */