Commit Graph

3755 Commits (f08480af78ef561644f42507c28ab1b6c7cba960)

Author SHA1 Message Date
Sam Lantinga f08480af78 Switched to new style gradle Android application build process 2017-10-23 15:23:43 -07:00
Sam Lantinga 862da6ff19 Added tag release-2.0.7 for changeset f69c9f74a857 2017-10-23 12:33:18 -07:00
Sven Hesse b89cac6761 Don't X error in SDL_CreateWindow with unsupported GL attributes 2017-10-22 20:24:58 +02:00
Sam Lantinga adc64f922f Added Visual Studio solution files for WinRT projects 2017-10-21 22:26:24 -07:00
Sam Lantinga 10376eb926 Fixed bug 3901 - Fix vsync-ed pageflips on the KMSDRM video driver
Manuel

I noticed that, at least on Intel GPU hardware, passing SDL_RENDERER_PRESENTVSYNC would result on a static console instead of the program graphics.
That was due to the fact that calling drmModePageFlip() only works if we have previously set up CRTC to one of the GBM buffers with a drmModeSetCrtc() call, so now it's done and things work as expected.

The KMSDRM_GLES_SetupCrtc() call is done only one time, only when needed (when egl_swapinterval is not 0: when it's 0, there's no need for it because we flip by calling drmModePageFlip() anyway).
The place where KMSDRM_GLES_SetupCrtc() call is done may look strange, but it's right: it needs EGL completely ready because it needs to call eglSwapBuffers() internally to work (see more comments about it in the code).
2017-10-21 04:20:57 -07:00
Sam Lantinga e830ef3458 Fixed typo converting 4 channel audio to 2 channel 2017-10-20 16:53:42 -07:00
Sam Lantinga 9a291c1e59 Added a note about adjusting channel weights when converting to fewer channels 2017-10-20 14:51:22 -07:00
Sam Lantinga fe2b5fec61 Document the SDL audio channel mapping 2017-10-20 14:48:10 -07:00
Sam Lantinga 7a6cf53aea Added SDL_AudioStreamFlush() to the list of new audio stream functions 2017-10-20 10:45:38 -07:00
Sam Lantinga c339d9ed6d Reverted changes 6acdea394736 and 1448a2ac30fe
I don't want to introduce any regressions with Android TV remote support
2017-10-20 10:29:22 -07:00
Sam Lantinga 2001898dce Fixed Android joystick detection 2017-10-19 15:37:52 -07:00
Ryan C. Gordon 729329068b audio: Added SDL_AudioStreamFlush(). 2017-10-19 18:05:42 -04:00
Sam Lantinga 9d9be45682 Don't use DPAD devices as joystick input on Android 2017-10-19 13:54:56 -07:00
Ryan C. Gordon e98920f5f3 Check correct variable for malloc() results. 2017-10-18 23:49:46 -04:00
Sam Lantinga afefcbfeba Fixed bug 3876 - Resampling of certain sounds adds heavy distortion
Simon Hug

Patch that adds [-1, 1] clamping to the scalar audio type conversions.

This may come from the SDL_Convert_F32_to_X_Scalar functions. They don't clamp the float value to [-1, 1] and when they cast it to the target integer it may be too large or too small for the type and get truncated, causing horrible noise.

The attached patch throws clamping in, but I don't know if that's the preferred way to fix this. For x86 (without SSE) the compiler (I tested MSVC) seems to throw a horrible amount of x87 code in it. It's a bit better with SSE, but probably still quite the performance hit. And SSE2 uses a branchless approach with maxss and minss.
2017-10-18 19:30:47 -07:00
Sam Lantinga 653ab5d9c4 Added a staging buffer to the audio stream so that we can accumulate small amounts of data if needed when resampling 2017-10-18 19:26:36 -07:00
Sam Lantinga 80f8464d97 Added audio stream conversion functions:
SDL_NewAudioStream
    SDL_AudioStreamPut
    SDL_AudioStreamGet
    SDL_AudioStreamAvailable
    SDL_AudioStreamClear
    SDL_FreeAudioStream
2017-10-18 15:54:05 -07:00
Sam Lantinga 9fd0d6191c Fixed bug 3821 - Allow SDL_CreateWindow and SDL_CreateRenderer with OpenGL ES 3.0 (GLES3) for Angle (Windows)
Carlos

Angle supports GLES3 but when using these functions (SDL_CreateWindow and SDL_CreateRenderer), defaults again to GLES2.0.

A current workaround (hack) to retrieve a GLES3.0 context with Angle is:

1) set

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);

after InitSDL AND after calling SDL_CreateWindow  (before SDL_CreateRenderer)

2) Comment lines 2032-2044 in SDL_render_gles2.c, funtion GLES2_CreateRenderer

    window_flags = SDL_GetWindowFlags(window);
    if (!(window_flags & SDL_WINDOW_OPENGL) ||
        profile_mask != SDL_GL_CONTEXT_PROFILE_ES || major != RENDERER_CONTEXT_MAJOR || minor != RENDERER_CONTEXT_MINOR) {

        changed_window = SDL_TRUE;
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, RENDERER_CONTEXT_MAJOR);
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, RENDERER_CONTEXT_MINOR);

        if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) {
            goto error;
        }
    }

This retrives a GLES3 context as confirmed using glGetString(GL_VERSION). This should be fixed by modifying a few if's.
2017-10-18 08:52:04 -07:00
Sam Lantinga 556a854438 Fixed compiler warning on iOS 2017-10-16 15:22:40 -07:00
Sam Lantinga e4ef1885d9 Fixed bug 3890 - Incomplete fix for CVE-2017-2888
Felix Geyer

http://hg.libsdl.org/SDL/rev/a31ee4d64ff6 tries to fix CVE-2017-2888.
Unfortunately compilers may optimize the second condition "(size / surface->pitch) != surface->h" away.
See https://bugzilla.redhat.com/show_bug.cgi?id=1500623#c2
I've verified that this is also the case on Debian unstable (gcc 7.2).
2017-10-16 14:57:42 -07:00
Sam Lantinga a225ffc1d7 Added min/max macros for the sized SDL datatypes 2017-10-16 14:39:56 -07:00
Sam Lantinga 8e98bdaa6f Fixed bug 3883 - SDL_assert / SDL_PromptAssertion in TTY mode does not accept options ("abriA")
shoerbaffen

fgets can read a newline and SDL_strcmp will never return zero.
2017-10-15 21:21:19 -07:00
Sam Lantinga f658a737f6 Fixed bug 3882 - cmake fix for osx
Ozkan Sezer

In my cross-build environment with cmake-2.8.12.1, cmake does not add
SDL_coreaudio.m to its makefiles and the result is a failure. The fix
is simple: set the language to C for it as it is done at other places
in CMakeLists.txt.
2017-10-15 21:07:01 -07:00
Sam Lantinga dff56c3497 Android Studio code analyzer fixes 2017-10-13 19:55:07 -07:00
Sam Lantinga a223560a7f Fixed bug 3880 - X Error upon quit since rev. 11607
Ozkan Sezer

Since changeset 11607:60cd425a2f14, I am getting the following
error upon quit.  Running testsprite2, clicking the mouse, and
quiting it is enough to trigger it.  This is on my old Fedora9
x86-Linux:

X Error of failed request:  BadCursor (invalid Cursor parameter)
  Major opcode of failed request:  2 (X_ChangeWindowAttributes)
  Resource id in failed request:  0xb057340
  Serial number of failed request:  905
  Current serial number in output stream:  906

Reverting  https://hg.libsdl.org/SDL/rev/60cd425a2f14  removes
the error.
2017-10-13 19:30:34 -07:00
Sam Lantinga cf9236488a Fixed bug 3879 - add missing SDLCALL to SDLTest_TrackedMalloc & co.
Ozkan Sezer

The attached trivial patch adds missing SDLCALL to SDLTest_TrackedMalloc & co.
2017-10-13 09:50:04 -07:00
Ryan C. Gordon fa15674134 coreaudio: changed device close procedure to prevent long hangs in some cases.
The audioqueue thread needs to keep running, and processing the CFRunLoop
until the AudioQueue is disposed of, otherwise CoreAudio will hang waiting for
final data to feed the device.

At least, I think this is how it all works. It definitely fixes the bug here!

Since AudioQueueDispose() calls AudioQueueStop() internally, there's no need
for our thread to handle this, either, which is good because the AudioQueue
would be disposed by this point. So now the AudioQueue is disposed first, and
then our thread is joined, and everything works out okay.

Just in case, we mark the device "paused" before setting everything in motion,
so any further callbacks from CoreAudio will write silence and not fire the
app's audio callback again.

Fixes Bugzilla #3868.
2017-10-13 01:15:29 -04:00
Sam Lantinga 0506d4fc42 Build both 32 and 64-bit architectures in the OSX Framework 2017-10-12 17:21:57 -07:00
Sam Lantinga fc60db86b3 Fixed compiler warning 2017-10-12 17:17:09 -07:00
Sam Lantinga 22b6df511b Use the lower-case hex output to match other stack trace printouts 2017-10-12 14:46:28 -07:00
Sam Lantinga 7079195697 Fixed compiler warning 2017-10-12 14:44:54 -07:00
Sam Lantinga 5fc2017661 Fixed bug 3877 - missing SDLCALL in SDLTest_ExampleHitTestCallback
Ozkan Sezer

Following trivial patch adds missing SDLCALL to SDLTest_ExampleHitTestCallback()
2017-10-12 14:25:07 -07:00
Sam Lantinga 4b28429882 Android doesn't have libunwind.h in API 16 2017-10-12 14:21:21 -07:00
Sam Lantinga 41a60394d0 Added missing file 2017-10-12 14:20:17 -07:00
Sam Lantinga 21cd2df694 Fixed compiler warning 2017-10-12 14:02:24 -07:00
Sam Lantinga ba10d2b654 Fixed compiler warning 2017-10-12 13:55:35 -07:00
Sam Lantinga 9c580e14c9 Added functions to query and set the SDL memory allocation functions:
SDL_GetMemoryFunctions()
    SDL_SetMemoryFunctions()
    SDL_GetNumAllocations()
2017-10-12 13:44:28 -07:00
Sam Lantinga 1887c54c68 Fixed memory leak in Cocoa mouse code
The video quit call cleans up the mouse cursor driver data, which happens after mouse quit
2017-10-12 13:28:48 -07:00
Sam Lantinga f4cd68a537 Fixed bug 3866 - CMake error when trying to make the 'uninstall' target when it already exists
Steve Robinson

In my project, the 'uninstall' target is already created by the glew library.  I get this error when SDL2 tries to create it:

CMake Error at _build/3rdparty/SDL2/SDL2-2.0.6/CMakeLists.txt:1816 (add_custom_target):
  add_custom_target cannot create target "uninstall" because another target
  with the same name already exists.  The existing target is a custom target
  created in source directory
  "D:/Code/sdl2-tutorial/_build/3rdparty/glew/glew-2.1.0/build/cmake".  See
  documentation for policy CMP0002 for more details.

To fix it, go to the bottom of the SDL2 CMakeLists.txt file.  Add an if statement to check for the existence of the target before creating it.  The end result looks like this:

if(NOT TARGET uninstall)
  configure_file(
      "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
      "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
      IMMEDIATE @ONLY)

  add_custom_target(uninstall
      COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()

This is how the glew library deals with this possibility in their CMakeLists.txt file.
2017-10-12 08:47:02 -07:00
Sam Lantinga 4f38db1735 Fixed bug 3867 - Can't find install_manifest.txt when running 'uninstall' target
Steve Robinson

When I try to build the 'uninstall' target in CMake when SDL2 is added to a subdirectory of my project, I get this error:

1>CMake Error at cmake_uninstall.cmake:2 (message):
1>  Cannot find install manifest:
1>  "D:/Code/sdl2-tutorial/_build/3rdparty/SDL2/SDL2-2.0.6/install_manifest.txt"

The install_manifest.txt is actually in the top-level binary directory, not the project-specific binary directory.

To fix it, change all instances of:
CMAKE_CURRENT_BINARY_DIR

To:
CMAKE_BINARY_DIR

In:
cmake_uninstall.cmake.in
2017-10-12 08:44:45 -07:00
Sam Lantinga f4f9e39f62 Fixed bug 3874 - Compiler warnings SDL_Surface.c and SDL_cocoakeyboard.m 2017-10-12 08:41:11 -07:00
Sam Lantinga a7c79c5e25 Normalize touch events to the render viewport (thanks Sylvain!) 2017-10-12 08:37:55 -07:00
Sam Lantinga 5bed4ca92e Fixed divide by zero with a 1x1 sized window 2017-10-12 08:27:22 -07:00
Ozkan Sezer bef0fec121 make sure that SDL_malloc(0) or SDL_calloc(0,x) doesn't return NULL. 2017-10-12 14:28:05 +03:00
Sam Lantinga 0ce23a5498 Updated version to 2.0.7 2017-10-12 08:08:04 -07:00
Ethan Lee 84fb4893cf Check SDL_UDEV_DYNAMIC first, then SDL_UDEV_LIBS separately 2017-10-10 20:22:15 -04:00
Sam Lantinga c0019b7f49 Fixed bug 3871 - Touch events are not normalised on X11
Trent Gamblin

The documentation for SDL_TouchFingerEvent says that the x and y coordinates are normalised between 0-1. I've found that to be true on Windows, Android and iOS but on X11 they are in pixel coordinates. This patch fixes the issue. This was the cleanest way I could do it with what was available without changing things around a lot but you may know a better way.
2017-10-11 13:31:21 -07:00
Sam Lantinga b53c35df43 Fixed size in realloc 2017-10-11 13:26:58 -07:00
Ryan C. Gordon 5e5f2290f2 audio: Turns out the accumulation errors sound better. :/
Moving to double fixed the overflows, but using "time = i * incr" instead of
"time += incr" causes clicks in the output.
2017-10-11 12:07:43 -04:00
Ryan C. Gordon 9bd2c6b491 audio: Moved the resampler state up to double precision.
Fixes more buffer overflows.
2017-10-11 11:51:14 -04:00