Commit Graph

3734 Commits (8e98bdaa6fe2b9055ef8ef5cf48d31a082cd5c5b)

Author SHA1 Message Date
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
Ryan C. Gordon b2f5123b65 audio: calculate resampling time directly, don't increment (thanks, Eric!).
Fixes buffer overruns as floating point errors accumulate.

Partially fixes Bugzilla #3848.
2017-10-11 11:43:35 -04:00
Ryan C. Gordon 763c387149 audio: clamp resampler interpolation values to prevent buffer overflow.
Partially fixes Bugzilla #3848.
2017-10-11 02:33:55 -04:00
Ryan C. Gordon 0085f917e0 audio: Moved unchanging variable out of loop. 2017-10-11 02:31:58 -04:00
Ryan C. Gordon cb8bf6bbaf audio: Make sure audio stream resampling doesn't overflow buffers. 2017-10-11 02:03:05 -04:00
Ryan C. Gordon 459e2b0bbe audio: Fixed check for minimum audio stream put size. 2017-10-11 01:37:11 -04:00
Sam Lantinga 0e495e83dd Updated WhatsNew.txt for 2.0.7 changes 2017-10-10 20:16:52 -07:00
Sam Lantinga 8446d4a05a Changed overlapping memcpy to memmove 2017-10-10 20:11:05 -07:00
Sam Lantinga eb9e6938cc Fixed potentially calling a callback after it has been removed (and userdata possibly deleted) 2017-10-10 19:44:33 -07:00
Ryan C. Gordon 903ff6414e audio: SDL_ResampleCVT() should use memmove instead of memcpy.
This copy can overlap.

Fixes Bugzilla #3849.
2017-10-10 22:31:02 -04:00
Ryan C. Gordon 42fff7ce2b audio: Don't stack-allocate resampler padding.
(I thought padding size ranged from 5 frames to ~30 frames (based around
RESAMPLER_ZERO_CROSSINGS, which is 5), but it's actually between 512 and
several thousands (based on RESAMPLER_SAMPLES_PER_ZERO_CROSSING)). It gets
big fast when downsampling.
2017-10-10 22:18:46 -04:00
Sam Lantinga b647bd0692 The event filter and event watch functions are now thread-safe 2017-10-10 17:41:41 -07:00
Ryan C. Gordon 37d89aa10f audio: reworked audio streams to have right-hand resampling padding available.
Fixes Bugzilla #3851.
2017-10-10 16:12:56 -04:00
Ryan C. Gordon 28149e11c8 Added SDL_PeekIntoDataQueue(). 2017-10-10 11:56:54 -04:00
Sam Lantinga d90fce3c9e Exposed the joystick locking functions for multi-threaded access to the joystick API 2017-10-10 11:10:15 -07:00
Sam Lantinga 2657dfae49 Fixed crash in SDL_IsGameController() on Windows if called when a controller is being removed 2017-10-09 11:45:15 -07:00
Sam Lantinga b120fb879a Fixed bug 3865 - [PATCH] Support for GreenAsia Inc. PSX to USB converter as SDL_GameController
Manuel

I would like this small patch merged that adds support for my GreenAsia Inc. PSX to USB converter, so SDL_IsGameController() returns true when using this adaptor.
It's interesting because PSX/PS2 controllers connected using this model won't be detected as gamecontrollers otherwise, only as joysticks.
2017-10-08 10:59:03 -07:00
Sam Lantinga d2a2b0c139 Fixed bug 3857 - SDL_ConvertPixels misses YUV conversions
Sylvain

There are various YUV-RGB conversion coefficients, according to https://www.fourcc.org/fccyvrgb.php
I choose the first (from Video Demystified, with integer multiplication),
but the current SDL2 Dither functions use in fact the next one, which follows a specifications called CCIR 601.

Here's a patch to use the second ones and with previous warning corrections.
There are less multiplications involved because Chroma coefficient is 1.
Also, doing float multiplication is as efficient with vectorization.
In the end, the YUV decoding is faster: ~165 ms vs my previous 195 ms.

Moreover, if SDL2 is compiled with -march=native, then YUV decoding time drops to ~130ms, while older ones remains around ~220 ms.


For information, from jpeg-9 source code:
jpeg-9/jccolor.c

   * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
   * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
   * The conversion equations to be implemented are therefore
   * Y  =  0.29900 * R + 0.58700 * G + 0.11400 * B
   * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B  + CENTERJSAMPLE
   * Cr =  0.50000 * R - 0.41869 * G - 0.08131 * B  + CENTERJSAMPLE

jpeg-9/jdcolor.c

   * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
   * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
   * The conversion equations to be implemented are therefore
   *
   * R = Y                + 1.40200 * Cr
   * G = Y - 0.34414 * Cb - 0.71414 * Cr
   * B = Y + 1.77200 * Cb
2017-10-07 15:26:55 -07:00
Sam Lantinga 1bfe6d6026 Fixed restoring window size when coming out of fullscreen desktop mode.
Use the style of the window as it will be, not as it currently is at the
time of the AdjustWindowRect call.
2017-10-06 21:43:59 -07:00
Sam Lantinga e9652b1987 Fixed bug 3857 - SDL_ConvertPixels misses YUV conversions
Sylvain

Few issues with YUV on SDL2 when using odd dimensions, and missing conversions from/back to YUV formats.

1) The big part is that SDL_ConvertPixels() does not convert to/from YUV in most cases. This now works with any format and also with odd dimensions,
  by adding two internal functions SDL_ConvertPixels_YUV_to_ARGB8888 and SDL_ConvertPixels_ARGB8888_to_YUV (could it be XRGB888 ?).
  The target format is hard coded to ARGB888 (which is the default in the internal of the software renderer).
  In case of different YUV conversion, it will do an intermediate conversion to a ARGB8888 buffer.

  SDL_ConvertPixels_YUV_to_ARGB8888 is somehow redundant with all the "Color*Dither*Mod*".
  But it allows some completeness of SDL_ConvertPixels to handle all YUV format.
  It also works with odd dimensions.

  Moreover, I did some benchmark(SDL_ConvertPixel vs Color32DitherYV12Mod1X and Color32DitherYUY2Mod1X).
  gcc-6.3 and clang-4.0. gcc performs better than clang. And, with gcc, SDL_ConvertPixels() performs better (20%) than the two C function Color32Dither*().
  For instance, to convert 10 times a 3888x2592 image, it takes ~195 ms with SDL_ConvertPixels and ~235 ms with Color32Dither*().
  Especially because of gcc vectorize feature that optimises all conversion loops (-ftree-loop-vectorize).

  Nb: I put no image pitch for the YUV buffers. because it complexify a little bit the code and the API :
  There would be some ambiguity when setting the pitch exactly to image width:
  would it a be pitch of image width (for luma and chroma). or just contiguous data ? (could set pitch=0 for the later).


2) Small issues with odd dimensions:
  If width "w" is odd, luma plane width is still "w" whereas chroma planes will be "(w + 1)/2". Almost the same for odd h.
  Solution is to strategically substitute "w" by "(w+1)/2" at the good places ...

- In the repository, SDL_ConvertPixels() handles YUV only if yuv source format is exactly the same as YUV destination format.
  It basically does a memcpy of pixels, but it's done incorrectly when width or height is odd (wrong size of chroma planes). This is fixed.

- SDL Renderers don't support odd width/height for YUV textures.
  This is fixed for software, opengl, opengles2. (opengles 1 does not support it and fallback to software rendering).
  This is *not* fixed for D3D and D3D11 ... (and others, psp ?)
  Only *two* Dither function are fixed ... not sure if others are really used.

- This is not possible to create a NV12/NV12 texture with the software renderer, whereas other renderers allow it.
  This is fixed, by using SDL_ConvertPixels underneath.

- It was not possible to SDL_UpdateTexture() of format NV12/NV21 with the software renderer. this is fixed.

Here's also two testcases:
- that do all combination of conversion.
- to test partial UpdateTexture
2017-10-06 16:50:24 -07:00
Sam Lantinga 827e985041 Fixed bug 3862 - Install is broken when adding SDL2 to an existing CMake project
Steve Robinson

In my existing CMake project, I use add_subdirectory to add the source for SDL2.  This worked fine in 2.0.5, but now in 2.0.6 when I build the INSTALL CMake target, I get this error:

file INSTALL cannot find "D:/path/to/SDL2Config.cmake".
Call Stack (most recent call first):
  3rdparty/SDL2/cmake_install.cmake:32 (include)
  3rdparty/cmake_install.cmake:36 (include)
  cmake_install.cmake:32 (include)

To fix this, I changed line 1770 from this:
${CMAKE_SOURCE_DIR}/SDL2Config.cmake

To this:
${CMAKE_CURRENT_SOURCE_DIR}/SDL2Config.cmake
2017-10-06 16:42:43 -07:00
Sam Lantinga d9e1036e0f Fixed potential overflow in surface allocation (thanks Yves!) 2017-10-06 16:17:50 -07:00