Commit Graph

142 Commits

Author SHA1 Message Date
Sam Lantinga
a9072159b2 Updated copyright for 2018 2018-01-03 10:03:25 -08:00
Sam Lantinga
57143a1183 Fixed bug 3745 - specify SDLCALL as the calling convention for API callbacks
Patches contributed by Ozkan Sezer
2017-08-14 06:28:21 -07:00
Sam Lantinga
75e7530ad2 Fixed bug 2764 - Timer is not rescheduled with the returned interval
afwlehmann

Sorry for re-opening, but it turns out that the current interval is indeed not updated. I've just checked the source code of the 2.0.3 release again:

   163	    if (current->canceled) {
   164	        interval = 0;
   165	    } else {
   166	        interval = current->callback(current->interval, current->param);
   167	    }
   168
   169	    if (interval > 0) {
   170	        /* Reschedule this timer */
   171	        current->interval = interval; // <-- this line is missing
   172	        current->scheduled = tick + interval;
   173	        SDL_AddTimerInternal(data, current);
   174	    } else {

According to the documentation: "The callback function is passed the current timer interval and the user supplied parameter from the SDL_AddTimer() call and returns the next timer interval. If the returned value from the callback is 0, the timer is canceled."

If I understand the text correctly, then the current interval should in fact be updated according to the returned value. Otherwise there would be a discrepancy between the next time for which the timer is actually re-scheduled and the value that's passed to the callback once the timer fires again.

This could be fixed by adding line #171.
2017-08-13 21:48:40 -07:00
Sam Lantinga
3412c450d0 Fixed bug 3744 - missing SDLCALL in several functions
Ozkan Sezer

The attached patch adds missing SDLCALL to several functions, so that
they properly match the headers as intended.
2017-08-13 21:06:52 -07:00
Philipp Wiesemann
c81af887b1 haiku: Changed header paths to be more compatible. 2017-07-29 23:00:14 +02:00
Sam Lantinga
d77ab77a7a Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Sam Lantinga
5e1151257d Patch from Sylvain to fix clang warnings 2016-11-13 22:57:41 -08:00
Philipp Wiesemann
1e4a104164 Windows: Fixed not removing the always added hint callback on quit.
This was no real problem because SDL_Quit() also calls SDL_ClearHints().
2016-10-16 22:47:37 +02:00
Ryan C. Gordon
5006582bed threads: Move SDL's own thread creation to a new internal API.
This allows us to set an explicit stack size (overriding the system default
and the global hint an app might have set), and remove all the macro salsa
for dealing with _beginthreadex and such, as internal threads always set those
to NULL anyhow.

I've taken some guesses on reasonable (and tiny!) stack sizes for our
internal threads, but some of these might turn out to be too small in
practice and need an increase. Most of them are simple functions, though.
2016-04-12 16:45:10 -04:00
Alex Szpakowski
ff2304cf06 Windows: make sure SDL_TicksInit has been called before calling Sleep(ms) in SDL_Delay. This ensures the Windows system timer resolution is properly set before Sleep is called. 2016-02-14 21:17:25 -04:00
Ryan C. Gordon
0e7135739a Remove almost all instances of "volatile" keyword.
As Tiffany pointed out in Bugzilla, volatile is not useful for thread safety:

https://software.intel.com/en-us/blogs/2007/11/30/volatile-almost-useless-for-multi-threaded-programming/

Some of these volatiles didn't need to be, some were otherwise protected by
spinlocks or mutexes, and some got moved over to SDL_atomic_t data, etc.

Fixes Bugzilla #3220.
2016-01-03 06:50:50 -05:00
Sam Lantinga
255c182471 Updated copyright to 2016 2016-01-02 10:10:34 -08:00
Sam Lantinga
cfce458df8 Use CLOCK_MONOTONIC_RAW, if available, which is not subject to adjustment by NTP 2015-06-19 23:49:00 -07:00
Sam Lantinga
78f2198e6c Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
Ryan C. Gordon
496c226acf Cleaned up the macro salsa in the Windows timer code.
- Removed USE_GETTICKCOUNT code; it's never used now.
- Reduced the number of preprocessor checks for WinRT.
- Renamed timeSetPeriod() so it doesn't look like a Win32 API call.
2015-04-20 13:43:24 -04:00
Ryan C. Gordon
c70b5d68b7 Windows: Always set the system timer resolution to 1ms by default.
An existing hint lets apps that don't need the timer resolution changed avoid
this, to save battery, etc, but this fixes several problems in timing, audio
callbacks not firing fast enough, etc.

Fixes Bugzilla #2944.
2015-04-20 12:22:44 -04:00
Philipp Wiesemann
e7bde43d07 Added missing guards in implementation for PSP.
Thanks to Martin Gerhardy for pointing this out.
2015-01-31 22:45:54 +01:00
Philipp Wiesemann
ee06d1bc3f Added missing include statements in implementation for PSP.
SDL_internal.h should be included to support dynamic API and fix warnings.
2015-01-31 22:43:05 +01:00
David Ludwig
8bd7d187f4 WinRT: build fix for Visual C++ 2013 Update 4
Visual C++ 2013 Update 4 re-introduced the Sleep() function to WinRT apps (for
code that targets Windows 8.1 and Windows Phone 8.1).  This led to a build
error, as SDL was defining it's own Sleep() function (to make up for the lack
of a public Sleep() function).  The fix makes sure that SDL's custom Sleep()
function is only used when Windows' Sleep() is not available.

Many thanks go out to Sergiu Marian Gaina for the fix!
2014-11-15 10:12:36 -05:00
Sam Lantinga
8c027a3cbe Fixed compiler warnings on iOS 2014-07-07 11:00:25 -07:00
Sam Clegg
5cc37d29ec Fix compiler warnings in Native Client and Linux builds. 2014-06-20 11:10:16 -03:00
Sam Lantinga
0ae88759fb Integrated David Ludwig's support for Windows RT 2014-03-09 11:36:47 -07:00
Sam Lantinga
32547d0c59 Fixed line endings on WinRT source code 2014-03-09 11:06:11 -07:00
Sam Lantinga
34d80ff6f0 Fixed bug 2423 - timeBeginPeriod & timeEndPeriod mismatch
Coriiander

In src\timer\windows\SDL_systimer.c there is an error with regards to timeBeginPeriod and timeEndPeriod. These functions typically get called when no high resolution timer is available, and GetTickCount is not used.

According to MSDN (link: http://msdn.microsoft.com/en-us/library/windows/desktop/dd757624(v=vs.85).aspx), for every call to timeBeginPeriod a subsequent call to timeEndPeriod is required. While SDL is currently doing this, it fails to call timeEndPeriod when cleaning up/shutting down SDL. Please note that these functions affect things on a system level. Failing to call timeEndPeriod, disables applications for using WINMM-timers after usage&shutdown of SDL, as effectively they the mechanism is now broken.

Solution:
Ensure this code gets called when shutting down the timer subsystem:

#ifndef USE_GETTICKCOUNT
if (!hires_timer_available)
{
    timeSetPeriod(0);
}
#endif
2014-03-01 09:50:52 -08:00
Sam Lantinga
dba255c1e5 Fixed bug 2374 - Update copyright for 2014...
Is it that time already??
2014-02-02 00:53:27 -08:00
Ryan C. Gordon
3dfc14ade2 Implemented the Dynamic API magic. 2013-12-09 16:03:18 -05:00
David Ludwig
c96c4f3dc4 WinRT: merged with latest SDL 2.x/HG code
SDL 2.x recently accepted patches to enable OpenGL ES 2 support via Google's ANGLE library.  The thought is to try to eventually merge SDL/WinRT's OpenGL code with SDL-official's.
2013-11-28 22:09:21 -05:00
Ryan C. Gordon
03d5719413 Make internal SDL sources include SDL_internal.h instead of SDL_config.h
The new header will include SDL_config.h, but allows for other global stuff.
2013-11-24 23:56:17 -05:00
Ryan C. Gordon
b444dd2714 Renamed things named after BeOS to be named after Haiku instead. 2013-11-14 11:51:24 -05:00
David Ludwig
529fcd3ee3 WinRT: merged with SDL 2.0.1 codebase 2013-10-27 21:26:46 -04:00
David Ludwig
1ae5d8dea3 WinRT: build fixes and additional WinRT-related integrations with SDL 2.0.0 2013-08-13 20:09:52 -04:00
Sam Lantinga
ab4156e1ac Fixed bug 1925 - SDL_GetPerformanceFrequency returns incorrect value on iOS
PoopiSan

Currently on OSX and iOS simulator the values:
mach_base_info.denom = 1
mach_base_info.numer = 1

but on the real iOS device
mach_base_info.denom = 3
mach_base_info.numer = 125

The calculation is made using following formula
mach_base_info.denom / mach_base_info.numer * 1000000

but all values are int32 and the result is casted to int64.

This solves the problem:

return 1.0 * mach_base_info.denom / mach_base_info.numer * 1000000;
2013-08-10 11:19:30 -07:00
Gabriel Jacobo
eefc8fdad1 Fixes bug #2074 - Thanks Sylvain!
SDL_syssem.c:159 comparison of unsigned expression >= 0 is always true
Solved by comparing unsigneds directly

SDL_systimer.c:164: warning: control may reach end of Compile
Solved by returning the default value if all else fails.

SDL_androidgl.c:41:1: warning: type specifier missing, defaults to 'int'
SDL_androidgl.c:47:1: warning: control reaches end of non-void function
Solved by adding void return type to the function implementation
2013-08-29 14:03:44 -03:00
Gabriel Jacobo
bc514bada3 Fixes for -Wdeclaration-after-statement 2013-08-21 10:12:16 -03:00
Ryan C. Gordon
a2907d64fc Patched to compile with Visual Studio. 2013-08-17 20:46:34 -04:00
Sam Lantinga
ec0aa51cec Fixed for consistency with the other platforms 2013-08-17 17:04:14 -07:00
Edward Rudd
3f7516d961 auto init the ticks if the GetTicks and the like methods are called before SDL_Init().. This prevents annoying game bugs such as caching SDL_GetPerformanceFrequency in a static initializer 2013-08-17 18:07:29 -04:00
Sam Lantinga
8f2f5f59d2 Added a hint to control the Windows timer resolution: SDL_HINT_TIMER_RESOLUTION
Added an API to watch hint changes: SDL_AddHintCallback(), SDL_DelHintCallback()
You can now dynamically set the joystick background event hint.
2013-07-13 03:13:41 -07:00
Sam Lantinga
924968d2d0 Updated timer test and fixed performance counter on Mac OS X 2013-06-23 22:19:38 -07:00
Sam Lantinga
0d9b661db8 File style cleanup for the SDL 2.0 release 2013-05-18 14:17:52 -07:00
Edward Rudd
908e617900 move Ticks initialization tracking to separate function and ensure it's called with SDL_VideoInit is called to init SDL instead of SDL_Init
-- why do we even allow initialization w/o calling at least SDL_Init(0) ?
2013-05-02 21:40:59 -04:00
Edward Rudd
79ed7900ca add in OS X Monotonic clock as well as handling fall-back incase the OSX/Linux system doesn't have a monotonic clock.
Code curtesy of Thomas Habets ( https://github.com/ThomasHabets/monotonic_clock )
2013-05-02 21:17:59 -04:00
Sam Lantinga
570f6639eb QueryPerformanceCounter() is reliable these days, and setting the timer frequency higher can have adverse power consequences.
http://msdn.microsoft.com/en-us/library/windows/desktop/dd757624%28v=vs.85%29.aspx
2013-05-02 16:54:03 -07:00
Sam Lantinga
f0af9a3e70 Removed Nintendo DS support since nobody has volunteered to maintain it for over a year. 2013-03-17 09:44:58 -07:00
Captain Lex
a18bccd5f3 Add PSP support 2013-03-17 20:07:02 +08:00
Sam Lantinga
2952d9bf48 Changed the name of SDL_mutexP() SDL_mutexV() 2013-03-07 20:12:40 -08:00
Sam Lantinga
019c60c1e8 Happy New Year! 2013-02-15 08:47:44 -08:00
Sam Lantinga
b3d60cfcbb Removed executable bit from source files 2012-09-27 14:35:28 -07:00
Ryan C. Gordon
b3b40aac16 Removed Windows CE support from SDL 2.0.
It's a long-dead platform, and we don't have any way to build for, test, or
maintain it, so there's no sense in doing acrobatics to support it.

If you need Windows CE support, use SDL 1.2. If you need Windows Phone support,
send SDL 2.0 patches for the newer Windows Mobile platform.
2012-09-15 10:59:39 -04:00
Sam Lantinga
e256711bb9 Happy New Year! 2011-12-31 09:28:07 -05:00