parent
16deaa9a72
commit
250fd42368
|
@ -53,8 +53,8 @@
|
||||||
/* Enable thread support */
|
/* Enable thread support */
|
||||||
#define SDL_THREAD_PTHREAD 1
|
#define SDL_THREAD_PTHREAD 1
|
||||||
|
|
||||||
/* Enable dummy timer support */
|
/* Enable timer support */
|
||||||
#define SDL_TIMER_DUMMY 1
|
#define SDL_TIMER_UNIX 1
|
||||||
|
|
||||||
/* Enable video drivers */
|
/* Enable video drivers */
|
||||||
#define SDL_VIDEO_DRIVER_GENODE_FB 1
|
#define SDL_VIDEO_DRIVER_GENODE_FB 1
|
||||||
|
|
|
@ -14,7 +14,6 @@ INC_DIR += $(SDL_PORT_DIR)/include/SDL
|
||||||
SRC_CC = video/SDL_genode_fb_video.cc \
|
SRC_CC = video/SDL_genode_fb_video.cc \
|
||||||
video/SDL_genode_fb_events.cc \
|
video/SDL_genode_fb_events.cc \
|
||||||
audio/SDL_genodeaudio.cc \
|
audio/SDL_genodeaudio.cc \
|
||||||
timer/SDL_systimer.cc \
|
|
||||||
loadso/SDL_loadso.cc
|
loadso/SDL_loadso.cc
|
||||||
|
|
||||||
INC_DIR += $(REP_DIR)/include/SDL \
|
INC_DIR += $(REP_DIR)/include/SDL \
|
||||||
|
@ -45,7 +44,8 @@ INC_DIR += $(SDL_DIR)/src/thread
|
||||||
SRC_C += cpuinfo/SDL_cpuinfo.c
|
SRC_C += cpuinfo/SDL_cpuinfo.c
|
||||||
|
|
||||||
# timer subsystem
|
# timer subsystem
|
||||||
SRC_C += timer/SDL_timer.c
|
SRC_C += timer/SDL_timer.c \
|
||||||
|
timer/unix/SDL_systimer.c
|
||||||
INC_DIR += $(SDL_DIR)/src/timer
|
INC_DIR += $(SDL_DIR)/src/timer
|
||||||
|
|
||||||
# video subsystem
|
# video subsystem
|
||||||
|
|
|
@ -1,103 +0,0 @@
|
||||||
/*
|
|
||||||
* \brief Genode-specific timer backend
|
|
||||||
* \author Christian Prochaska
|
|
||||||
* \date 2012-03-13
|
|
||||||
*
|
|
||||||
* based on the dummy SDL timer
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2012-2017 Genode Labs GmbH
|
|
||||||
*
|
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
|
||||||
* under the terms of the GNU Affero General Public License version 3.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <timer_session/connection.h>
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "SDL_config.h"
|
|
||||||
|
|
||||||
#include "SDL_timer.h"
|
|
||||||
#include "SDL_timer_c.h"
|
|
||||||
|
|
||||||
|
|
||||||
static unsigned long start_ms = 0;
|
|
||||||
|
|
||||||
static Timer::Connection _timer;
|
|
||||||
|
|
||||||
|
|
||||||
void SDL_StartTicks(void)
|
|
||||||
{
|
|
||||||
start_ms = _timer.elapsed_ms();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Uint32 SDL_GetTicks (void)
|
|
||||||
{
|
|
||||||
return _timer.elapsed_ms() - start_ms;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SDL_Delay (Uint32 ms)
|
|
||||||
{
|
|
||||||
_timer.msleep(ms);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#include "SDL_thread.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* Data to handle a single periodic alarm */
|
|
||||||
static int timer_alive = 0;
|
|
||||||
static SDL_Thread *timer = NULL;
|
|
||||||
|
|
||||||
static int RunTimer(void *unused)
|
|
||||||
{
|
|
||||||
while ( timer_alive ) {
|
|
||||||
if ( SDL_timer_running ) {
|
|
||||||
SDL_ThreadedTimerCheck();
|
|
||||||
}
|
|
||||||
SDL_Delay(1);
|
|
||||||
}
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* This is only called if the event thread is not running */
|
|
||||||
int SDL_SYS_TimerInit(void)
|
|
||||||
{
|
|
||||||
timer_alive = 1;
|
|
||||||
timer = SDL_CreateThread(RunTimer, NULL);
|
|
||||||
if ( timer == NULL )
|
|
||||||
return(-1);
|
|
||||||
return(SDL_SetTimerThreaded(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SDL_SYS_TimerQuit(void)
|
|
||||||
{
|
|
||||||
timer_alive = 0;
|
|
||||||
if ( timer ) {
|
|
||||||
SDL_WaitThread(timer, NULL);
|
|
||||||
timer = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int SDL_SYS_StartTimer(void)
|
|
||||||
{
|
|
||||||
SDL_SetError("Internal logic error: threaded timer in use");
|
|
||||||
return(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SDL_SYS_StopTimer(void)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue