Comments (5)
I believe there is a mistake in the conversion formula of the
SDL_CondWaitTimeout implementation:
clock_gettime(&now);
abstime.tv_sec = now.tv_sec + (ms / 1000);
abstime.tv_nsec = (now.tv_nsec + (ms % 1000) * 1000) * 1000;
The last line code should be:
abstime.tv_nsec = now.tv_nsec + ((ms % 1000) * 1000) * 1000;
Original comment by [email protected]
on 5 Nov 2014 at 4:32
from sdl-wii.
Moreover clock_gettime should return the elapsed time from 1970.
Whilst LWP_CondTimedWait expects the time elapsed from the CPU bootstrap (i.e.
clicks).
So clock_gettime is the wrong function to use in this case.
gettime() should be used instead along with ticks_to_secs and tick_nanosecs
functions of lwp_watchdog.h.
Anyhow also tick_nanosecs of libogc is buggy.
Moreover also clock_gettime is buggy since in the current wrong implementation
the tv_sec is calculated as the seconds elapsed from 1970 and tv_nsec (which
should be the number of nanoseconds expired in the current second) is the
nanoseconds elapsed from the CPU bootstrap.
See my post here:
http://devkitpro.org/viewtopic.php?f=3&t=3056
Original comment by [email protected]
on 14 Dec 2014 at 12:50
from sdl-wii.
I believe that the correct implementation should be
#include <ogc/lwp_watchdog.h>
int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
{
struct timespec now;
struct timespec abstime;
u64 ticks;
if (!cond)
{
SDL_SetError("Passed a NULL condition variable");
return -1;
}
ticks=gettime();
now.tv_sec = ticks_to_secs(ticks);
#define tick_nanosecs(ticks)
((((u64)(ticks)*8000)/(u64)(TB_TIMER_CLOCK/125))%1000000000) //To remove when
it will be fixed il libogc
now.tv_nsec = tick_nanosecs(ticks);
abstime.tv_sec = now.tv_sec + (ms / 1000);
abstime.tv_nsec = now.tv_nsec + ((ms % 1000) * 1000) * 1000;
if (abstime.tv_nsec > 1000000000)
{
abstime.tv_sec += 1;
abstime.tv_nsec -= 1000000000;
}
return LWP_CondTimedWait(cond->cond, mutex->id, &abstime);
}
Original comment by [email protected]
on 14 Dec 2014 at 1:14
from sdl-wii.
Indeed I checked that WP_CondTimedWait's timespec parameter passes relative
time instead of absolute time as specified in the documentation. So the
implementation should be:
int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
{
struct timespec time;
if (!cond)
{
SDL_SetError("Passed a NULL condition variable");
return -1;
}
time.tv_sec = (ms / 1000);
time.tv_nsec = (ms % 1000) * 1000000;
return LWP_CondTimedWait(cond->cond, mutex->id, &time);
}
Original comment by [email protected]
on 21 Dec 2014 at 5:38
from sdl-wii.
Committed the changes in the SVN
Original comment by [email protected]
on 21 Dec 2014 at 5:59
- Changed state: Fixed
from sdl-wii.
Related Issues (20)
- Undefined references to KEYBOARD functions HOT 1
- Keyboard has to be reconnected again to work :-( HOT 3
- Put SDL in portlibs directory? HOT 1
- Crash when unloading OGG music file HOT 2
- Wont compile HOT 2
- SMPEG Linking Errors When Using SDL_Mixer HOT 2
- Library does not work properly with libogc 1.8.7 HOT 1
- LIBPNG VERSION HOT 4
- SDL_Delay HOT 1
- SDL_image does not compile HOT 2
- Mouse emulation not working. HOT 3
- configure script fails due to devkitPPC unitptr_t conflict HOT 10
- Stereo for sound effects is reversed. HOT 1
- Mouse sensitivity HOT 2
- 640 X 512 screen resolution
- Font redering HOT 3
- Wireless USB Keyboard not working
- Gamecube controller support HOT 2
- SDL_KillThread is not working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdl-wii.