Commit graph

10645 commits

Author SHA1 Message Date
Sam Lantinga
80fbdd08d4 Moved the meta-data into the right section 2017-11-01 18:40:11 -07:00
Sam Lantinga
f1d9b98e83 Fixed bug 3926 - SDL_main export
e_pluschauskas

I noticed that after updating SDL to 2.0.6 my application now exports SDL_main.

At GitHub SDL mirror (branch 2.0.5) SDL_main prototyped as
extern C_LINKAGE int SDL_main(int argc, char *argv[]);
but at branch 2.0.6 prototype is
extern C_LINKAGE DECLSPEC int SDL_main(int argc, char *argv[]);
2017-11-01 17:41:25 -07:00
Sam Lantinga
4254c060fa Fixed bug 3932 - Android, GetDisplayDPI release local reference
Sylvain

When writing JNI code, one has to make sure all local references are released otherwise the app end up crashing.
2017-11-01 17:30:02 -07:00
Sam Lantinga
42b997becf Fixed building on non-Android platforms 2017-11-01 10:07:04 -07:00
Sam Lantinga
7565396bf0 Added controller mapping for Android TV remotes
Also fixed the back button on the remote exiting the application
2017-11-01 10:06:58 -07:00
Sam Lantinga
e9bd005f5d Add SDL_GetDisplayDPI implementation on Android. (thanks Rachel!) 2017-10-31 13:49:59 -07:00
David Ludwig
d141e59bf5 WinRT: Move Windows::Foundation::Initialize to SDL2.dll, from SDL_main.
This allows C# UWP applications to use SDL2's SDL_WinRTRunApp function.

Kudos to Ethan Lee (flibitijibibo@flibitijibibo.com) for the patch.  Thanks!
2017-10-24 13:21:11 -04:00
Sam Lantinga
580856933d Fixed Java string comparison with "" 2017-10-29 21:09:09 -07:00
Sam Lantinga
9d580dd242 Added the old ant Android build project structure 2017-10-28 12:11:25 -07:00
Brandon Schaefer
93cc24f934 Fixed bug 3902 - Add a specific KMSDRM hint for low latency video
--HG--
extra : amend_source : 533faafd8a7c6832c94728550b1ca10bab2a8018
2017-10-26 16:37:20 -07:00
Sam Lantinga
876a6b2319 Updated SDL iOS project for tvOS 2017-10-26 10:49:33 -07:00
Sam Lantinga
c1c8f0b7e9 Added missing keyinfotable.h 2017-10-26 10:42:14 -07:00
Sam Lantinga
156e5e86d1 android: Fix softkeyboard issue in SDL on Android. 2017-10-26 10:41:38 -07:00
Ryan C. Gordon
76eb51cec1 cocoa: Don't change the NSWindow background color.
Changing the background color causes the titlebar to blend against it on
modern macOS releases, making all SDL windows look wrong by default. This was
set to make the window not flash white before a GL context is ready, but we
can accomplish this in our window's view's drawRect implementation, too.

--HG--
extra : rebase_source : 65e74179013cefad065806b058cf02016a235fa9
2017-10-25 18:02:11 -04:00
Sam Lantinga
b985a686f1 Added the ability to set SDL hints from AndroidManifest.xml (thanks Rachel!)
This is especially useful for things like the accelerometer hint which could be needed before application main().
2017-10-24 00:17:07 -07:00
Sam Lantinga
6cba336d1c Fixed crash if mSurface isn't set up when we pause the application 2017-10-24 00:04:40 -07:00
Sam Lantinga
f3da7593a5 Removed unneeded file automatically generated by Android Studio 2017-10-23 23:35:04 -07:00
Sam Lantinga
bb43a2bf53 Updated the minimum and target SDK versions in AndroidManifest.xml 2017-10-23 23:26:40 -07:00
Sam Lantinga
8216efa3bd Updated Android build tools version, which bumped minimum deployment target to API 14
Also added native code to the Android gradle project, which allows using gradle or Android Studio to build the entire SDL application without a separate ndk-build step.
2017-10-23 23:23:47 -07:00
Sam Lantinga
3406fdde97 Fixed build with older Android SDK 2017-10-23 23:23:34 -07:00
Sam Lantinga
cea35f5176 Switched to new style gradle Android application build process
--HG--
rename : android-project/jni/src/Android.mk => android-project/app/jni/src/Android.mk
rename : android-project/src/org/libsdl/app/SDL.java => android-project/app/src/main/java/org/libsdl/app/SDL.java
rename : android-project/src/org/libsdl/app/SDLAudioManager.java => android-project/app/src/main/java/org/libsdl/app/SDLAudioManager.java
rename : android-project/src/org/libsdl/app/SDLControllerManager.java => android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
2017-10-23 15:23:43 -07:00
Sam Lantinga
14531cf0fc Added tag release-2.0.7 for changeset 2088cd828335 2017-10-23 12:33:18 -07:00
Sven Hesse
80ef80f4b0 Don't X error in SDL_CreateWindow with unsupported GL attributes 2017-10-22 20:24:58 +02:00
Sam Lantinga
fb2544ea5e Added Visual Studio solution files for WinRT projects 2017-10-21 22:26:24 -07:00
Sam Lantinga
c1427cdb32 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
14a98894c7 Fixed typo converting 4 channel audio to 2 channel 2017-10-20 16:53:42 -07:00
Sam Lantinga
063e162d7d Added a note about adjusting channel weights when converting to fewer channels 2017-10-20 14:51:22 -07:00
Sam Lantinga
24ef59e969 Document the SDL audio channel mapping 2017-10-20 14:48:10 -07:00
Sam Lantinga
4a7f0378ce Added SDL_AudioStreamFlush() to the list of new audio stream functions 2017-10-20 10:45:38 -07:00
Sam Lantinga
ee92ece12a Reverted changes a970b2ae1bd7 and 4a94743e31fe
I don't want to introduce any regressions with Android TV remote support
2017-10-20 10:29:22 -07:00
Sam Lantinga
a96285279b Fixed Android joystick detection 2017-10-19 15:37:52 -07:00
Ryan C. Gordon
6656b81b42 audio: Added SDL_AudioStreamFlush().
--HG--
extra : rebase_source : 5bd3136ca1bcda9dcde4b2f6ab4891789e83331b
2017-10-19 18:05:42 -04:00
Sam Lantinga
9e88e62fac Don't use DPAD devices as joystick input on Android 2017-10-19 13:54:56 -07:00
Ryan C. Gordon
cbdd27d273 Check correct variable for malloc() results. 2017-10-18 23:49:46 -04:00
Sam Lantinga
dd27ac6305 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
8538f75119 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
f36e701b48 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
1146cf3022 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
38152d5f9c Fixed compiler warning on iOS 2017-10-16 15:22:40 -07:00
Sam Lantinga
e73a5f0dff Fixed bug 3890 - Incomplete fix for CVE-2017-2888
Felix Geyer

http://hg.libsdl.org/SDL/rev/7e0f1498ddb5 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
fc917367af Added min/max macros for the sized SDL datatypes 2017-10-16 14:39:56 -07:00
Sam Lantinga
65cba5bab4 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
4418242860 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
f803b34112 Android Studio code analyzer fixes 2017-10-13 19:55:07 -07:00
Sam Lantinga
6b368f890b Fixed bug 3880 - X Error upon quit since rev. 11607
Ozkan Sezer

Since changeset 11607:db7ee6a1ba6a, 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/db7ee6a1ba6a  removes
the error.
2017-10-13 19:30:34 -07:00
Sam Lantinga
fd1f3a8aef 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
e8c14464e7 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.

--HG--
extra : rebase_source : 3b8ba6f8c5af56b8193ea1bd96ef8b9111533f87
2017-10-13 01:15:29 -04:00
Sam Lantinga
c78d61d079 Build both 32 and 64-bit architectures in the OSX Framework 2017-10-12 17:21:57 -07:00
Sam Lantinga
c750316a19 Fixed compiler warning 2017-10-12 17:17:09 -07:00
Sam Lantinga
c8fa5fcfd5 Use the lower-case hex output to match other stack trace printouts 2017-10-12 14:46:28 -07:00