aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2003-09-27 16:54:11 +0000
committerMax Horn2003-09-27 16:54:11 +0000
commit49d2a22b428864ccf2298b67841d4cb3cf33b659 (patch)
tree11f1ebd799bec7e853bc71671fa045fe9467774c
parente19e7c879a1fc88458a3e26715875e60512d755b (diff)
downloadscummvm-rg350-49d2a22b428864ccf2298b67841d4cb3cf33b659.tar.gz
scummvm-rg350-49d2a22b428864ccf2298b67841d4cb3cf33b659.tar.bz2
scummvm-rg350-49d2a22b428864ccf2298b67841d4cb3cf33b659.zip
OSystem changes: removed create_thread() method (not needed anymore; 'pure' threads aren't very portable anyway, better we only use timers); introduced OSystem::TimerProc type
svn-id: r10430
-rw-r--r--backends/PalmOS/Src/palm.cpp27
-rw-r--r--backends/PalmOS/Src/palm.h24
-rw-r--r--backends/dc/audio.cpp2
-rw-r--r--backends/dc/dc.h9
-rw-r--r--backends/dc/dcmain.cpp5
-rw-r--r--backends/dc/time.cpp2
-rw-r--r--backends/gp32/gp32.cpp7
-rw-r--r--backends/gp32/gp32.h7
-rw-r--r--backends/morphos/morphos.cpp27
-rw-r--r--backends/morphos/morphos.h12
-rw-r--r--backends/null/null.cpp3
-rw-r--r--backends/sdl/sdl-common.cpp8
-rw-r--r--backends/sdl/sdl-common.h8
-rw-r--r--backends/wince/wince.cpp18
-rw-r--r--backends/wince/wince.h10
-rw-r--r--backends/x11/x11.cpp21
-rw-r--r--common/system.h23
-rw-r--r--common/timer.cpp2
18 files changed, 47 insertions, 168 deletions
diff --git a/backends/PalmOS/Src/palm.cpp b/backends/PalmOS/Src/palm.cpp
index a1bf3a760a..a9e4ef0691 100644
--- a/backends/PalmOS/Src/palm.cpp
+++ b/backends/PalmOS/Src/palm.cpp
@@ -646,22 +646,7 @@ void OSystem_PALMOS::delay_msecs(uint msecs) {
SysTaskDelay((SysTicksPerSecond()*msecs)/1000);
}
-void OSystem_PALMOS::create_thread(ThreadProc *proc, void *param) {
- if (_threadCounter == MAX_THREAD) {
- warning("Cannot create thread.");
- return;
- }
-
- _thread[_threadCounter].active = true;
- _thread[_threadCounter].proc = proc;
- _thread[_threadCounter].param = param;
- _thread[_threadCounter].old_time = get_msecs();
- _thread[_threadCounter].sleep = true;
-
- _threadCounter++;
-}
-
-void OSystem_PALMOS::set_timer(int timer, int (*callback)(int)) {
+void OSystem_PALMOS::set_timer(TimerProc callback, int timer) {
if (callback != NULL) {
_timer.duration = timer;
_timer.next_expiry = get_msecs() + timer;
@@ -729,11 +714,6 @@ bool OSystem_PALMOS::poll_event(Event *event) {
}
current_msecs = get_msecs();
- //thread handler
- for(_threadID = 0; _threadID < _threadCounter; _threadID++) {
- if (_thread[_threadID].active)
- _thread[_threadID].proc(_thread[_threadID].param);
- }
// sound handler
if(_sound.active)
@@ -1242,9 +1222,6 @@ OSystem_PALMOS::OSystem_PALMOS() {
_paletteDirtyEnd = 0;
memset(&_sound, 0, sizeof(SoundDataType));
- memset(_thread, 0, sizeof(_thread));
- _threadID = 0;
- _threadCounter = 0;
_currentPalette = NULL;
@@ -1350,7 +1327,7 @@ void OSystem_PALMOS::move_screen(int dx, int dy, int height) {
SysTaskDelay(1);
}
-bool OSystem_PALMOS::set_sound_proc(SoundProc *proc, void *param, SoundFormat format) {
+bool OSystem_PALMOS::set_sound_proc(SoundProc proc, void *param, SoundFormat format) {
_sound.active = true;
_sound.proc = proc;
_sound.param = param;
diff --git a/backends/PalmOS/Src/palm.h b/backends/PalmOS/Src/palm.h
index f2d157e623..e9d6fc93d6 100644
--- a/backends/PalmOS/Src/palm.h
+++ b/backends/PalmOS/Src/palm.h
@@ -31,20 +31,9 @@ Err HwrDisplayPalette(UInt8 operation, Int16 startIndex,
UInt16 paletteEntries, RGBColorType *tableP)
SYS_TRAP(sysTrapHwrDisplayPalette);
-#define MAX_THREAD 2
-
-typedef struct {
- bool active;
- OSystem::ThreadProc *proc;
- void *param;
- bool sleep;
- int old_time;
-
-} ThreadEmuType, *ThreadEmuPtr;
-
typedef struct {
bool active;
- OSystem::SoundProc *proc;
+ OSystem::SoundProc proc;
void *param;
OSystem::SoundFormat format;
SndStreamRef sndRefNum;
@@ -95,9 +84,6 @@ public:
// Delay for a specified amount of milliseconds
void delay_msecs(uint msecs);
- // Create a thread
- void create_thread(ThreadProc *proc, void *param);
-
// Get the next event.
// Returns true if an event was retrieved.
bool poll_event(Event *event);
@@ -113,7 +99,7 @@ public:
* @param param an arbitrary parameter which is stored and passed to proc.
* @param format the sample type format.
*/
- bool set_sound_proc(SoundProc *proc, void *param, SoundFormat format);
+ bool set_sound_proc(SoundProc proc, void *param, SoundFormat format);
/**
* Remove any audio callback previously set via set_sound_proc, thus effectively
@@ -137,7 +123,7 @@ public:
void update_cdrom();
// Add a callback timer
- void set_timer(int timer, int (*callback)(int));
+ void set_timer(TimerProc callback, int timer);
// Mutex handling
MutexRef create_mutex();
@@ -200,10 +186,6 @@ public:
int _offScreenPitch;
int _screenPitch;
- ThreadEmuType _thread[MAX_THREAD]; // 0: midi native, 1:multi-midi (adlib wrapper)
- UInt8 _threadCounter;
- UInt8 _threadID;
-
private:
byte *_offScreenP;
diff --git a/backends/dc/audio.cpp b/backends/dc/audio.cpp
index 22c1015189..12a66dec9c 100644
--- a/backends/dc/audio.cpp
+++ b/backends/dc/audio.cpp
@@ -34,7 +34,7 @@ void initSound()
do_sound_command(CMD_SET_BUFFER(3));
}
-bool OSystem_Dreamcast::set_sound_proc(SoundProc *proc, void *param, SoundFormat format)
+bool OSystem_Dreamcast::set_sound_proc(SoundProc proc, void *param, SoundFormat format)
{
#if SAMPLE_MODE == 0
assert(format == SOUND_16BIT);
diff --git a/backends/dc/dc.h b/backends/dc/dc.h
index e022976de9..e2839396c6 100644
--- a/backends/dc/dc.h
+++ b/backends/dc/dc.h
@@ -44,15 +44,12 @@ class OSystem_Dreamcast : public OSystem {
// Delay for a specified amount of milliseconds
void delay_msecs(uint msecs);
- // Create a thread
- void create_thread(ThreadProc *proc, void *param);
-
// Get the next event.
// Returns true if an event was retrieved.
bool poll_event(Event *event);
// Set function that generates samples
- bool set_sound_proc(SoundProc *proc, void *param, SoundFormat format);
+ bool set_sound_proc(SoundProc proc, void *param, SoundFormat format);
void clear_sound_proc();
// Poll cdrom status
@@ -82,7 +79,7 @@ class OSystem_Dreamcast : public OSystem {
void copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h);
// Add a callback timer
- virtual void set_timer(int timer, int (*callback)(int));
+ virtual void set_timer(TimerProc callback, int timer);
// Mutex handling
virtual MutexRef create_mutex();
@@ -104,7 +101,7 @@ class OSystem_Dreamcast : public OSystem {
int _current_shake_pos, _screen_w, _screen_h;
int _overlay_x, _overlay_y;
unsigned char *_ms_buf;
- SoundProc *_sound_proc;
+ SoundProc _sound_proc;
void *_sound_proc_param;
bool _overlay_visible, _overlay_dirty, _screen_dirty;
int _screen_buffer, _overlay_buffer, _mouse_buffer;
diff --git a/backends/dc/dcmain.cpp b/backends/dc/dcmain.cpp
index a9c758a578..bca55bcc25 100644
--- a/backends/dc/dcmain.cpp
+++ b/backends/dc/dcmain.cpp
@@ -127,11 +127,6 @@ void OSystem_Dreamcast::quit() {
exit(0);
}
-void OSystem_Dreamcast::create_thread(ThreadProc *proc, void *param) {
- warning("Creating a thread! (not supported.)\n");
-}
-
-
/* Mutex handling */
OSystem::MutexRef OSystem_Dreamcast::create_mutex()
{
diff --git a/backends/dc/time.cpp b/backends/dc/time.cpp
index d0dda69b8c..3821294238 100644
--- a/backends/dc/time.cpp
+++ b/backends/dc/time.cpp
@@ -53,7 +53,7 @@ void OSystem_Dreamcast::delay_msecs(uint msecs)
get_msecs();
}
-void OSystem_Dreamcast::set_timer(int timer, int (*callback)(int))
+void OSystem_Dreamcast::set_timer(TimerProc callback, int timer)
{
if (callback != NULL) {
_timer_duration = timer;
diff --git a/backends/gp32/gp32.cpp b/backends/gp32/gp32.cpp
index e78f185aa5..5eba66274a 100644
--- a/backends/gp32/gp32.cpp
+++ b/backends/gp32/gp32.cpp
@@ -858,9 +858,6 @@ void OSystem_GP32::delay_msecs(uint msecs) {
while ( ( GpTickCountGet() - n ) < msecs) ;
}
-// Create a thread
-void OSystem_GP32::create_thread(ThreadProc *proc, void *param) { }
-
// Get the next event.
// Returns true if an event was retrieved.
@@ -979,7 +976,7 @@ bool OSystem_GP32::poll_event(Event *event) { // fixme: make more user-friendly
// Set the function to be invoked whenever samples need to be generated
// Format is the sample type format.
// Only 16-bit signed mode is needed for simon & scumm
-bool OSystem_GP32::set_sound_proc(SoundProc *proc, void *param, SoundFormat format) {
+bool OSystem_GP32::set_sound_proc(SoundProc proc, void *param, SoundFormat format) {
return false;
}
@@ -1076,7 +1073,7 @@ void OSystem_GP32::stop_cdrom() { }
void OSystem_GP32::update_cdrom() { }
// Add a new callback timer
-void OSystem_GP32::set_timer(int timer, int (*callback)(int)) { }
+void OSystem_GP32::set_timer(TimerProc callback, int timer) { }
// Mutex handling
OSystem::MutexRef OSystem_GP32::create_mutex() {
diff --git a/backends/gp32/gp32.h b/backends/gp32/gp32.h
index 0b3f3dd338..0faf3f0cf2 100644
--- a/backends/gp32/gp32.h
+++ b/backends/gp32/gp32.h
@@ -73,9 +73,6 @@ public:
// Delay for a specified amount of milliseconds
void delay_msecs(uint msecs);
- // Create a thread
- void create_thread(ThreadProc *proc, void *param);
-
// Get the next event.
// Returns true if an event was retrieved.
bool poll_event(Event *event);
@@ -83,7 +80,7 @@ public:
// Set the function to be invoked whenever samples need to be generated
// Format is the sample type format.
// Only 16-bit signed mode is needed for simon & scumm
- bool set_sound_proc(SoundProc *proc, void *param, SoundFormat format);
+ bool set_sound_proc(SoundProc proc, void *param, SoundFormat format);
void clear_sound_proc();
// Get or set a property
@@ -103,7 +100,7 @@ public:
void update_cdrom();
// Add a new callback timer
- void set_timer(int timer, int (*callback)(int));
+ void set_timer(TimerProc callback, int timer);
// Mutex handling
OSystem::MutexRef create_mutex();
diff --git a/backends/morphos/morphos.cpp b/backends/morphos/morphos.cpp
index d565a57d6c..c98a8d305d 100644
--- a/backends/morphos/morphos.cpp
+++ b/backends/morphos/morphos.cpp
@@ -97,7 +97,6 @@ OSystem_MorphOS::OSystem_MorphOS(SCALERTYPE gfx_mode, bool full_screen)
ScummScreenBuffer[1] = NULL;
ScummRenderTo = NULL;
ScummNoCursor = NULL;
- ScummMusicThread = NULL;
ScummSoundThread = NULL;
ScummWinX = -1;
ScummWinY = -1;
@@ -323,24 +322,11 @@ void OSystem_MorphOS::delay_msecs(uint msecs)
TimeDelay(UNIT_MICROHZ, 0, msecs*1000);
}
-void OSystem_MorphOS::set_timer(int timer, int (*callback)(int))
+void OSystem_MorphOS::set_timer(TimerProc callback, int timer)
{
warning("set_timer() unexpectedly called");
}
-void OSystem_MorphOS::create_thread(ThreadProc *proc, void *param)
-{
- MusicStartup.mn_Node.ln_Type = NT_MESSAGE;
- MusicStartup.mn_ReplyPort = ThreadPort;
- MusicStartup.mn_Length = sizeof(MusicStartup);
-
- ScummMusicThread = CreateNewProcTags(NP_Entry, (ULONG) proc, NP_CodeType, CODETYPE_PPC,
- NP_Name, (ULONG) "ScummVM Music Thread",
- NP_Priority, 40, NP_StackSize, 32000,
- NP_StartupMsg, &MusicStartup,
- NP_PPC_Arg1, (ULONG) param, TAG_DONE);
-}
-
OSystem::MutexRef OSystem_MorphOS::create_mutex()
{
SignalSemaphore *sem = (SignalSemaphore *) AllocVec(sizeof (SignalSemaphore), MEMF_PUBLIC);
@@ -518,13 +504,6 @@ void OSystem_MorphOS::quit()
{
int num_threads = 0;
- if (ScummMusicThread)
- {
- num_threads++;
- Signal((Task *) ScummMusicThread, SIGBREAKF_CTRL_C);
- ScummMusicThread = NULL;
- }
-
if (ScummSoundThread)
{
num_threads++;
@@ -532,6 +511,8 @@ void OSystem_MorphOS::quit()
ScummSoundThread = NULL;
}
+ // TODO: this code could probably greatly simplified now that there is
+ // only one thread left...
while (num_threads > 0)
{
Message* msg;
@@ -1463,7 +1444,7 @@ void OSystem_MorphOS::set_mouse_cursor(const byte *buf, uint w, uint h, int hots
UndrawMouse();
}
-bool OSystem_MorphOS::set_sound_proc(OSystem::SoundProc *proc, void *param, OSystem::SoundFormat format)
+bool OSystem_MorphOS::set_sound_proc(OSystem::SoundProc proc, void *param, OSystem::SoundFormat format)
{
if (ScummSoundThread)
{
diff --git a/backends/morphos/morphos.h b/backends/morphos/morphos.h
index 3164af83b4..deea09bbf7 100644
--- a/backends/morphos/morphos.h
+++ b/backends/morphos/morphos.h
@@ -37,7 +37,7 @@
class OSystem_MorphOS : public OSystem
{
public:
- OSystem_MorphOS(SCALERTYPE gfx_mode, bool full_screen);
+ OSystem_MorphOS(SCALERTYPE gfx_mode, bool full_screen);
virtual ~OSystem_MorphOS();
bool Initialise();
@@ -85,7 +85,7 @@ class OSystem_MorphOS : public OSystem
virtual void delay_msecs(uint msecs);
// Add a new callback timer
- virtual void set_timer(int timer, int (*callback)(int));
+ virtual void set_timer(TimerProc callback, int timer);
// Mutex handling
virtual MutexRef create_mutex();
@@ -93,9 +93,6 @@ class OSystem_MorphOS : public OSystem
virtual void unlock_mutex(MutexRef mutex);
virtual void delete_mutex(MutexRef mutex);
- // Create a thread
- virtual void create_thread(ThreadProc *proc, void *param);
-
// Get the next event.
// Returns true if an event was retrieved.
virtual bool poll_event(Event *event);
@@ -104,7 +101,7 @@ class OSystem_MorphOS : public OSystem
virtual void warp_mouse(int x, int y);
// Set the function to be invoked whenever samples need to be generated
- virtual bool set_sound_proc(SoundProc *proc, void *param, SoundFormat format);
+ virtual bool set_sound_proc(SoundProc proc, void *param, SoundFormat format);
void fill_sound (byte * stream, int len);
void clear_sound_proc();
@@ -180,9 +177,8 @@ class OSystem_MorphOS : public OSystem
ColorMap *OvlCMap;
/* Sound-related attributes */
- Process *ScummMusicThread;
Process *ScummSoundThread;
- SoundProc *SoundProc;
+ SoundProc SoundProc;
void *SoundParam;
MsgPort *ThreadPort;
Message MusicStartup;
diff --git a/backends/null/null.cpp b/backends/null/null.cpp
index b4eb5f87c9..6e2f870709 100644
--- a/backends/null/null.cpp
+++ b/backends/null/null.cpp
@@ -40,9 +40,8 @@ public:
void set_shake_pos(int shake_pos) {}
uint32 get_msecs();
void delay_msecs(uint msecs);
- void create_thread(ThreadProc *proc, void *param) { }
bool poll_event(Event *event) { return false; }
- bool set_sound_proc(SoundProc *proc, void *param, SoundFormat format) {}
+ bool set_sound_proc(SoundProc proc, void *param, SoundFormat format) {}
void quit() { exit(1); }
uint32 property(int param, Property *value) { return 0; }
static OSystem *create(int gfx_mode, bool full_screen);
diff --git a/backends/sdl/sdl-common.cpp b/backends/sdl/sdl-common.cpp
index 7a407ad385..ecfc114844 100644
--- a/backends/sdl/sdl-common.cpp
+++ b/backends/sdl/sdl-common.cpp
@@ -83,7 +83,7 @@ void OSystem_SDL_Common::init_intern(int gfx_mode, bool full_screen, bool aspect
}
}
-void OSystem_SDL_Common::set_timer(int timer, int (*callback)(int)) {
+void OSystem_SDL_Common::set_timer(TimerProc callback, int timer) {
SDL_SetTimer(timer, (SDL_TimerCallback) callback);
}
@@ -507,10 +507,6 @@ void OSystem_SDL_Common::delay_msecs(uint msecs) {
SDL_Delay(msecs);
}
-void OSystem_SDL_Common::create_thread(ThreadProc *proc, void *param) {
- SDL_CreateThread(proc, param);
-}
-
static int mapKey(SDLKey key, SDLMod mod, Uint16 unicode)
{
if (key >= SDLK_F1 && key <= SDLK_F9) {
@@ -900,7 +896,7 @@ bool OSystem_SDL_Common::poll_event(Event *event) {
return false;
}
-bool OSystem_SDL_Common::set_sound_proc(SoundProc *proc, void *param, SoundFormat format) {
+bool OSystem_SDL_Common::set_sound_proc(SoundProc proc, void *param, SoundFormat format) {
SDL_AudioSpec desired;
memset(&desired, 0, sizeof(desired));
diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h
index a36ea2dbff..78ecba892b 100644
--- a/backends/sdl/sdl-common.h
+++ b/backends/sdl/sdl-common.h
@@ -28,7 +28,6 @@
#include "backends/intern.h"
#include <SDL.h>
-#include <SDL_thread.h>
class OSystem_SDL_Common : public OSystem {
public:
@@ -68,15 +67,12 @@ public:
// Delay for a specified amount of milliseconds
void delay_msecs(uint msecs);
- // Create a thread
- void create_thread(ThreadProc *proc, void *param);
-
// Get the next event.
// Returns true if an event was retrieved.
bool poll_event(Event *event);
// Set function that generates samples
- bool set_sound_proc(SoundProc *proc, void *param, SoundFormat format);
+ bool set_sound_proc(SoundProc proc, void *param, SoundFormat format);
void clear_sound_proc();
@@ -100,7 +96,7 @@ public:
uint32 property(int param, Property *value);
// Add a callback timer
- void set_timer(int timer, int (*callback)(int));
+ void set_timer(TimerProc callback, int timer);
// Mutex handling
MutexRef create_mutex();
diff --git a/backends/wince/wince.cpp b/backends/wince/wince.cpp
index 86fe31a486..86e3ec8043 100644
--- a/backends/wince/wince.cpp
+++ b/backends/wince/wince.cpp
@@ -64,9 +64,6 @@ typedef struct
#define CURRENT_KEYS_VERSION 3
-typedef int (*tTimeCallback)(int);
-typedef void SoundProc(void *param, byte *buf, int len);
-
// Dynamically linked Aygshell
typedef BOOL (*tSHFullScreen)(HWND,DWORD);
//typedef BOOL (WINSHELLAPI *tSHHandleWMSettingChange)(HWND,WPARAM,LPARAM,SHACTIVATEINFO*);
@@ -371,7 +368,7 @@ extern Scumm *g_scumm;
//OSystem *g_system;
//SoundMixer *g_mixer;
Config *g_config;
-tTimeCallback timer_callback;
+OSystem::TimerProc timer_callback;
int timer_interval;
tSHFullScreen dynamicSHFullScreen = NULL;
@@ -444,7 +441,7 @@ dirty_square ds[MAX_NUMBER_OF_DIRTY_SQUARES];
int num_of_dirty_square;
-SoundProc *real_soundproc;
+OSystem::SoundProc real_soundproc;
extern void startFindGame();
extern void displayGameInfo();
@@ -1347,7 +1344,7 @@ OSystem *OSystem_WINCE3_create() {
return OSystem_WINCE3::create(0, 0);
}
-void OSystem_WINCE3::set_timer(int timer, int (*callback)(int)) {
+void OSystem_WINCE3::set_timer(TimerProc callback, int timer) {
if (!SetTimer(hWnd, 1, timer, NULL))
exit(1);
timer_interval = timer;
@@ -1705,13 +1702,6 @@ void OSystem_WINCE3::delay_msecs(uint msecs) {
Sleep(msecs);
}
-void OSystem_WINCE3::create_thread(ThreadProc *proc, void *param) {
- // needed for emulated MIDI support (Sam'n'Max)
- HANDLE handle;
- handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)proc, param, 0, NULL);
- SetThreadPriority(handle, THREAD_PRIORITY_NORMAL);
-}
-
int mapKey(int key, byte mod)
{
if (key>=VK_F1 && key<=VK_F9) {
@@ -1763,7 +1753,7 @@ void own_soundProc(void *buffer, byte *samples, int len) {
memset(samples, 0, len);
}
-bool OSystem_WINCE3::set_sound_proc(SoundProc *proc, void *param, SoundFormat format) {
+bool OSystem_WINCE3::set_sound_proc(SoundProc proc, void *param, SoundFormat format) {
SDL_AudioSpec desired;
/* only one format supported at the moment */
diff --git a/backends/wince/wince.h b/backends/wince/wince.h
index 1c9bb4bd9a..d4cd0660da 100644
--- a/backends/wince/wince.h
+++ b/backends/wince/wince.h
@@ -50,9 +50,6 @@
#include "SDL.h"
-#include "SDL_audio.h"
-#include "SDL_timer.h"
-#include "SDL_thread.h"
#include "dynamic_imports.h"
@@ -108,15 +105,12 @@ public:
// Delay for a specified amount of milliseconds
void delay_msecs(uint msecs);
- // Create a thread
- void create_thread(ThreadProc *proc, void *param);
-
// Get the next event.
// Returns true if an event was retrieved.
bool poll_event(Event *event);
// Set function that generates samples
- bool set_sound_proc(SoundProc *proc, void *param, SoundFormat format);
+ bool set_sound_proc(SoundProc proc, void *param, SoundFormat format);
// Poll cdrom status
// Returns true if cd audio is playing
@@ -132,7 +126,7 @@ public:
void update_cdrom();
// Add a new callback timer
- void set_timer(int timer, int (*callback)(int));
+ void set_timer(TimerProc callback, int timer);
// Quit
void quit();
diff --git a/backends/x11/x11.cpp b/backends/x11/x11.cpp
index 37b3ec69a4..e8a73321a3 100644
--- a/backends/x11/x11.cpp
+++ b/backends/x11/x11.cpp
@@ -89,15 +89,12 @@ public:
// Delay for a specified amount of milliseconds
void delay_msecs(uint msecs);
- // Create a thread
- void create_thread(ThreadProc *proc, void *param);
-
// Get the next event.
// Returns true if an event was retrieved.
bool poll_event(Event *event);
// Set function that generates samples
- bool set_sound_proc(SoundProc *proc, void *param, SoundFormat format);
+ bool set_sound_proc(SoundProc proc, void *param, SoundFormat format);
void clear_sound_proc();
@@ -121,7 +118,7 @@ public:
uint32 property(int param, Property *value);
// Add a callback timer
- void set_timer(int timer, int (*callback) (int));
+ void set_timer(TimerProc callback, int interval);
// Mutex handling
MutexRef create_mutex();
@@ -199,7 +196,7 @@ private:
};
typedef struct {
- OSystem::SoundProc *sound_proc;
+ OSystem::SoundProc sound_proc;
void *param;
byte format;
} THREAD_PARAM;
@@ -212,7 +209,7 @@ static void *sound_and_music_thread(void *params)
/* Init sound */
int sound_fd, param, frag_size;
uint8 sound_buffer[FRAG_SIZE];
- OSystem::SoundProc *sound_proc = ((THREAD_PARAM *) params)->sound_proc;
+ OSystem::SoundProc sound_proc = ((THREAD_PARAM *) params)->sound_proc;
void *proc_param = ((THREAD_PARAM *) params)->param;
#ifdef CAPTURE_SOUND
@@ -441,7 +438,7 @@ void OSystem_X11::init_size(uint w, uint h)
palette = (uint16 *)calloc(256, sizeof(uint16));
}
-bool OSystem_X11::set_sound_proc(SoundProc *proc, void *param, SoundFormat format)
+bool OSystem_X11::set_sound_proc(SoundProc proc, void *param, SoundFormat format)
{
static THREAD_PARAM thread_param;
@@ -779,12 +776,6 @@ void OSystem_X11::set_shake_pos(int shake_pos)
new_shake_pos = shake_pos;
}
-void OSystem_X11::create_thread(ThreadProc *proc, void *param)
-{
- pthread_t *thread = (pthread_t *) malloc(sizeof(pthread_t));
- pthread_create(thread, NULL, (void *(*)(void *))proc, param);
-}
-
uint32 OSystem_X11::property(int param, Property *value)
{
switch (param) {
@@ -1029,7 +1020,7 @@ bool OSystem_X11::poll_event(Event *scumm_event)
return false;
}
-void OSystem_X11::set_timer(int timer, int (*callback) (int))
+void OSystem_X11::set_timer(TimerProc callback, int interval)
{
if (callback != NULL) {
_timer_duration = timer;
diff --git a/common/system.h b/common/system.h
index e59bbe4632..4da287e980 100644
--- a/common/system.h
+++ b/common/system.h
@@ -33,15 +33,14 @@
* and use it to interact with the system.
*
* In particular, a backend provides a video surface for ScummVM to draw in;
- * methods to create threads and timers, to handle user input events,
+ * methods to create timers, to handle user input events,
* control audio CD playback, and sound output.
*/
class OSystem {
public:
typedef struct Mutex *MutexRef;
- typedef int ThreadProc(void *param);
- typedef void SoundProc(void *param, byte *buf, int len);
- //typedef int TimerProc(int interval);
+ typedef void (*SoundProc)(void *param, byte *buf, int len);
+ typedef int (*TimerProc)(int interval);
/**
* The types of events backends can generate.
@@ -213,7 +212,7 @@ public:
- /** @name Events and Threads */
+ /** @name Events and Time */
//@{
/** Get the number of milliseconds since the program was started. */
@@ -222,16 +221,8 @@ public:
/** Delay/sleep for the specified amount of milliseconds. */
virtual void delay_msecs(uint msecs) = 0;
- /**
- * Create a thread with the given entry procedure.
- * @param proc the thread main procedure
- * @param param an arbitrary parameter which is stored and passed to proc
- * @return
- */
- virtual void create_thread(ThreadProc *proc, void *param) = 0;
-
- /** Add a new callback timer. */
- virtual void set_timer(int timer, int (*callback)(int)) = 0;
+ /** Set the timer callback. */
+ virtual void set_timer(TimerProc callback, int interval) = 0;
/**
* Get the next event in the event queue.
@@ -253,7 +244,7 @@ public:
* @param param an arbitrary parameter which is stored and passed to proc.
* @param format the sample type format.
*/
- virtual bool set_sound_proc(SoundProc *proc, void *param, SoundFormat format) = 0;
+ virtual bool set_sound_proc(SoundProc proc, void *param, SoundFormat format) = 0;
/**
* Remove any audio callback previously set via set_sound_proc, thus effectively
diff --git a/common/timer.cpp b/common/timer.cpp
index 243eba2872..e8d6e24c4e 100644
--- a/common/timer.cpp
+++ b/common/timer.cpp
@@ -46,7 +46,7 @@ Timer::Timer(OSystem *system) :
_thisTime = _system->get_msecs();
// Set the timer last, after everything has been initialised
- _system->set_timer(10, &timer_handler);
+ _system->set_timer(&timer_handler, 10);
}