Commit graph

9484 commits

Author SHA1 Message Date
Ryan C. Gordon
cbb4c1dc3b Better fix for static analysis issue in SDL_DestroyRenderer().
Follow up fix for Bugzilla #3544.
2017-01-06 21:17:33 -05:00
Ryan C. Gordon
29c6f748df emscripten-buildbot.sh: let user override default SDKDIR. 2017-01-06 20:00:17 -05:00
Sam Lantinga
376e6fa6f2 Added support for using libsamplerate to do audio resampling 2017-01-06 02:16:26 -08:00
Sam Lantinga
b2161da809 Fixed confusion between Ryan's new audio stream and the audio buffer we were calling stream in the callback 2017-01-06 00:47:42 -08:00
Sam Lantinga
3cbab22892 Just roll back the entire portion of the commit from b6ec7005ca15 which caused bug 3544 until we figure out what the right static analysis fix is. 2017-01-06 00:40:22 -08:00
Ryan C. Gordon
70c33e0441 audio: Add an assert to make sure non-streaming audio uses good buffer sizes.
--HG--
extra : rebase_source : 80db5ce8cde0774915b7bc68542e1a58a49d6f18
2017-01-06 03:38:14 -05:00
Sam Lantinga
17e16c2e64 Fixed bug 3544 - Memory freeing bug in SDL_DestroyRenderer/SDL_DestroyTexture
felix

Here's a snippet of SDL_DestroyRenderer from hg revision 10746:95c57a177719:

    SDL_Texture *texture = NULL;
    SDL_Texture *nexttexture = NULL;
    /* ... */
    for (texture = renderer->textures; texture; texture = nexttexture) {
        nexttexture = texture->next;
        SDL_DestroyTexture(texture);
    }

SDL_DestroyTexture removes the texture from the linked list pointed to by the renderer and ends up calling SDL_DestroyTextureInternal, which contains this:

    if (texture->native) {
        SDL_DestroyTexture(texture->native);
    }

If it happens that texture->native is an alias of nexttexture two stack frames up, SDL_DestroyRenderer will end up trying to destroy an already freed texture. I've had this very situation happen in dosemu2.

Bug introduced in revision 10650:b6ec7005ca15, which has a somewhat ironic description of "Fixed all known static analysis bugs"...
2017-01-06 00:32:06 -08:00
Ryan C. Gordon
82b913d92c haiku: Patched to compile.
--HG--
extra : rebase_source : 358fa3054f6c237605fd57c64adf42dd0beeabdd
2017-01-06 03:15:27 -05:00
Sam Lantinga
2373e22054 Don't do any audio conversion if none is necessary 2017-01-05 23:53:46 -08:00
Sam Lantinga
a215c06f22 Fixed bug 3546 - SDL_EVDEV_is_console() uses type of wrong size when calling ioctl
Rob

When calling ioctl(fd, KDGKBTYPE, &type) in SDL_EVDEV_is_console(), we declare type as an 'int'.  This should be a 'char'.  The subsequent syscall, and kernel code, only writes the lower byte of the word.

See: http://lxr.free-electrons.com/source/drivers/tty/vt/vt_ioctl.c?v=4.4#L399

ucval = KB_101;
ret = put_user(ucval, (char __user *)arg);

I've observed intermittent behavior related to this, and I can force an error condition by using an int initialized to 0xFFFFFFFF.  The resulting ioctl will set type to 0XFFFFFF02, and the conditional return in SDL_EVDEV_is_console() will fail.

Recommend changing to char, or masking off unused bits.
2017-01-05 23:26:13 -08:00
Ryan C. Gordon
d8788062d4 audio: rename fake_stream to work_buffer.
It's more than an alternative for when the OS can't provide a DMA buffer, now.
2017-01-06 01:07:34 -05:00
Ryan C. Gordon
29fb138f51 audio: Fixed SDL_AudioStreamGet() function parameters.
There was a draft of this where it did audio conversion into the final buffer,
if there was enough room available past what you asked for, but that interface
got removed, so the parameters didn't make sense (and we were using the
wrong one in any case, too!).
2017-01-06 01:02:58 -05:00
Ryan C. Gordon
e93c4d4639 naclaudio: Untested attempt to migrate to SDL_AudioStream. 2017-01-06 00:56:29 -05:00
Ryan C. Gordon
f6a4c94ecc haikuaudio: Untested attempt to get this working with SDL_AudioStream. 2017-01-06 00:50:01 -05:00
Ryan C. Gordon
b2691868b7 emscriptenaudio: don't get stuck in infinite loop if SDL_AudioStreamPut fails. 2017-01-06 00:49:35 -05:00
Ryan C. Gordon
bd307581b6 emscriptenaudio: Reworked to use SDL_AudioStream.
--HG--
extra : amend_source : ef370fe4cb3d7446d1af21a0d452bd4393909e7a
2017-01-05 21:31:02 -05:00
Ryan C. Gordon
591dff71c2 Fixed a few compiler warnings. 2017-01-05 20:11:19 -05:00
Ryan C. Gordon
d629ac2d67 Patched to compile on some compilers.
--HG--
extra : histedit_source : 7b348321ae168305eceacdf3a966c0f0c7f24514
2017-01-05 19:45:57 -05:00
Ryan C. Gordon
70608017eb audio: Added SDL_AudioStream. Non-power-of-two resampling now works!
--HG--
extra : rebase_source : f6b2eb0c8a4d8869879112d60abe32962839fe7a
2017-01-05 19:29:38 -05:00
Ryan C. Gordon
02fd7b4a1e audio: More effort to improve and simplify audio resamplers.
--HG--
extra : rebase_source : a46522900178929c58d4e5442f710eb1ae31e91e
2017-01-05 19:12:20 -05:00
Ryan C. Gordon
884507a69e diskaudio: Use SDL_Log, not fprintf.
--HG--
extra : rebase_source : 66ffa127677e612d7cec47003cec9eb1c6486df3
2017-01-05 19:30:45 -05:00
Sam Lantinga
4aefa49d72 Fixed signedness issue when blitting on a big endian platform, as reported by capehill
For example, if sR is 0 and dR is 255, we will get -255*sA casted to an unsigned value. Basically results are quite large numbers instead of the expected 0-255 range.
2017-01-05 08:16:39 -08:00
Sam Lantinga
25b315f121 Fixed build warning on Haiku 2017-01-05 02:53:29 -08:00
Sam Lantinga
724ff3b29e Added SDL_JoystickGetAxisInitialState() to get a joystick axis' initial value.
This is useful for controller mapping programs to determine an axis' zero state
2017-01-04 10:28:07 -08:00
Sam Lantinga
c52ae60869 Assume D-pad or thumbstick style axes are centered at 0 2017-01-04 07:06:48 -08:00
Sam Lantinga
72e436f178 Added mappings for several GameCube and SNES controllers 2017-01-04 06:21:17 -08:00
Sam Lantinga
e1ea1486a3 Added the NEXT SNES Controller to the list of zero-centered joysticks 2017-01-04 06:19:56 -08:00
Sam Lantinga
c67ac27dc9 Increased joystick jitter tolerance for PS3 controllers 2017-01-04 05:56:47 -08:00
Sam Lantinga
03a927b4e3 Some controllers have trouble getting out to 20000 2017-01-04 05:09:02 -08:00
Ryan C. Gordon
a63f4a2448 x11: deal with xrandr display size in millimeters being zero.
Xquartz on macOS reports a zero size, which leads to a division by zero here.

--HG--
extra : rebase_source : 141e0acbf28bf42a0aa51d03b09f9f5cb3b7e46b
2017-01-04 09:33:47 -05:00
Sam Lantinga
40924be014 Fixed binding the D-pad on some Super NES style controllers
Fixed a case where partial trigger pull could be bound to another button

There is a fundamental problem not resolved by this commit:

Some controllers have axes (triggers, pedals, etc.) that don't start at zero, but we're guaranteed that if we get a value that it's correct. For these controllers, the current code works, where we take the first value we get and use that as the zero point and generate axis motion starting from that point on.

Other controllers have digital axes (D-pad) that assume a zero starting point, and the first value we get is the min or max axis value when the D-pad is moved. For these controllers, the current code thinks that the zero point is the axis value after the D-pad motion and this doesn't work.

My hypothesis is that the first class of devices is more common and that we should solve for that, and add an exception to SDL_JoystickAxesCenteredAtZero() as needed for the second class of devices.
2017-01-03 23:39:28 -08:00
Sam Lantinga
2b49698e2b Fixed bug 3519 - SDL_GetDisplayMode fails to report mode.format when using Wayland backend
Ryan C. Gordon

Kristian says you can't do it with Wayland, and that going forward, it'll just handle whatever you throw at it anyhow.

https://twitter.com/hoegsberg/status/816148272402165761

So I say we mark it SDL_PIXELFORMAT_RGB888, which is what my X11 display currently reports, and leave it at that.
2017-01-03 00:44:05 -08:00
Ryan C. Gordon
7949864901 Added SDL_ReserveSpaceInDataQueue() to make space without copying data.
--HG--
extra : rebase_source : f49b615025d83e0abc994ad23eb18b03eabd2530
extra : histedit_source : c361c4ff4e1f6f0e6fcce7d4324bb02fd70fab48
2016-12-27 23:48:43 -05:00
Sam Lantinga
dc9605265c Fixed bug 3539 - SDL2, missing MIR LDFLAGS
Gianfranco

Hello, this is the failure I got

https://launchpadlibrarian.net/300679206/buildlog_ubuntu-zesty-amd64.libsdl2_2.0.5+dfsg1-2ubuntu1_BUILDING.txt.gz

  LTLINK build/libSDL2.la
build/.libs/SDL_mirvideo.o: In function `MIR_InitDisplayFromOutput':
././src/video/mir/SDL_mirvideo.c:258: undefined reference to `mir_output_get_current_mode'
collect2: error: ld returned 1 exit status
2017-01-02 10:30:32 -08:00
Sam Lantinga
a3acad6d63 Fixed bug 3529 - SDL_EGL_UnloadLibrary is not called at all on SDL_Quit
kaisyu

In case of OpenGLES, the sequences of loading and unloading driver library should be like that:

SDL_Init
  ...
  SDL_GL_LoadLibrary
    SDL_EGL_LoadLibrary
...
SDL_Quit
  ...
  SDL_GL_UnloadLibrary
    SDL_EGL_UnloadLibrary
...


However, according to my test results, the varible '_this->gl_config.driver_loaded' does not allow 'SDL_GL_UnloadLibrary' to call 'SDL_EGL_UnloadLibrary'.
2017-01-01 19:10:36 -08:00
David Ludwig
13666b37a0 improved SDL_GetError() output generated by EGL code
This change attempts to report the EGL error codes generated by SDL's calls
into EGL, along with the name of the EGL function that failed.
2016-12-29 11:49:18 -05:00
Sam Lantinga
ca6961fa33 Run sed in binary mode so we don't have to worry about fixing line endings 2017-01-01 18:47:29 -08:00
Sam Lantinga
46f2d195d1 Fixed typo in copyright update script 2017-01-01 18:36:35 -08:00
Sam Lantinga
1b24bfad38 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Sam Lantinga
818a882d93 Convert some files back into DOS line endings after updating copyright 2017-01-01 18:32:57 -08:00
Sam Lantinga
ce62fef153 We don't currently support blitting to < 8 bpp surfaces, return an error instead of corrupting memory in that case. 2016-12-31 18:11:19 -08:00
Sam Lantinga
0ed729faa8 Fixed bug 3535 - Misplaced comment #if/#endif closure comment
Coriiander

This notice is about a misplaced comment.

Often times when we use an #if #endif sequence, the #endif is followed by a comment to indicate what #if statement it belonged to. The SDL_xaudio2.c file contains a misplaced comment, as follows (I stripped the other comments):

#ifdef __GNUC__
#  define SDL_XAUDIO2_HAS_SDK 1
#elif defined(__WINRT__)
#  define SDL_XAUDIO2_HAS_SDK
#include "SDL_xaudio2.h"
#else
#if 0
#include <dxsdkver.h>
#if (!defined(_DXSDK_BUILD_MAJOR) || (_DXSDK_BUILD_MAJOR < 1284))
#  pragma message("Your DirectX SDK is too old. Disabling XAudio2 support.")
#else
#  define SDL_XAUDIO2_HAS_SDK 1
#endif
#endif
#endif /* 0 */



That final /* 0 */ should be moved one line up. Like this (I tabbed it out for you to make it more clear):
2016-12-31 16:21:55 -08:00
Sam Lantinga
c2ab4c5a76 Fixed bug 3531 - internal SDL_vsnprintf implementation access memory outside given buffer ranges
Tristan

The internal SDL_vsnprintf implementation accesses memory outside buffer. The bug existed also inside the format (%) processing, which was fixed with Bug 3441.

But there is still an invalid access, if we do not have any format inside the source string and the destination string is shorter than the format string. You can use any string for this test, as long it is longer than the buffer.

Example:

va_list argList;
char buffer[4];
SDL_vsnprintf(buffer, sizeof(buffer), "Testing", argList);

The bug is located on the 'else' branch of the format char test:

while (*fmt) {
  if (*fmt == '%') {
    ...
  } else {
    if (left > 1) {
      *text = *fmt;
      --left;
    }
    ++fmt;
    ++text;
  }
}
if (left > 0) {
  *text = '\0';
}

As you can see that text is always incremented, even when left is already one. When then on the last lines, *text is assigned the NULL char, the pointer is located outside bounds.
2016-12-31 16:14:51 -08:00
Sam Lantinga
d792e20444 Fixed bug 3541 - DisplayIndex out of bounds in SDL_SetWindowPosition
Intellectual Kitty

In SDL_video.c, on line #1756, in SDL_SetWindowPosition (from today's distribution, 12-31-2016, https://hg.libsdl.org/SDL/shortlog/fe1e3dfa67ef):

        if (displayIndex > _this->num_displays) {

should be:

        if (displayIndex >= _this->num_displays) {
2016-12-31 10:30:07 -08:00
Philipp Wiesemann
9fa61fb93c Fixed warning and missing animation delay in testoverlay2 program. 2016-12-30 19:57:50 +01:00
Philipp Wiesemann
c8d8045c0d Fixed compiling of testgamecontroller program with C++. 2016-12-28 20:11:29 +01:00
Philipp Wiesemann
f848ed47c9 Fixed warning about unused variable in controllermap program. 2016-12-28 20:11:12 +01:00
Philipp Wiesemann
1a24600b5f Fixed crash if allocating memory for game controller failed. 2016-12-28 20:10:48 +01:00
Sam Lantinga
c47f2e6558 Added documentation for the game controller axis values 2016-12-27 09:59:36 -08:00
Sam Lantinga
899ab7a827 Make sure we go all the way back (within the XBox controller dead zone) to prevent accidentally binding axes inverted 2016-12-27 09:51:58 -08:00