mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-11 19:54:03 +00:00
SDL backend: got rid of setTimerCallback and clearSoundCallback
svn-id: r24446
This commit is contained in:
parent
b635a2fb84
commit
f4d8920f2b
@ -135,7 +135,6 @@ public:
|
||||
// Set function that generates samples
|
||||
typedef void (*SoundProc)(void *param, byte *buf, int len);
|
||||
virtual bool setSoundCallback(SoundProc proc, void *param); // overloaded by CE backend
|
||||
void clearSoundCallback();
|
||||
virtual Audio::Mixer *getMixer();
|
||||
|
||||
// Poll CD status
|
||||
@ -154,10 +153,6 @@ public:
|
||||
// Quit
|
||||
virtual void quit(); // overloaded by CE backend
|
||||
|
||||
|
||||
// Add a callback timer
|
||||
typedef int (*TimerProc)(int interval);
|
||||
void setTimerCallback(TimerProc callback, int timer);
|
||||
virtual Common::TimerManager *getTimerManager();
|
||||
|
||||
// Mutex handling
|
||||
@ -373,6 +368,8 @@ protected:
|
||||
|
||||
Common::SaveFileManager *_savefile;
|
||||
Audio::Mixer *_mixer;
|
||||
|
||||
SDL_TimerID _timerID;
|
||||
Common::TimerManager *_timer;
|
||||
|
||||
|
||||
|
@ -46,9 +46,9 @@ int __stdcall WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/, LPSTR /*lpC
|
||||
}
|
||||
#endif
|
||||
|
||||
static int timer_handler(int t) {
|
||||
DefaultTimerManager *tm = (DefaultTimerManager *)g_system->getTimerManager();
|
||||
return tm->handler(t);
|
||||
static Uint32 timer_handler(Uint32 interval, void *param) {
|
||||
((DefaultTimerManager *)param)->handler();
|
||||
return interval;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
@ -196,8 +196,15 @@ void OSystem_SDL::initBackend() {
|
||||
// Create and hook up the timer manager, if none exists yet (we check for
|
||||
// this to allow subclasses to provide their own).
|
||||
if (_timer == 0) {
|
||||
// TODO: We could implement a custom SDLTimerManager by using
|
||||
// SDL_AddTimer. That might yield better timer resolution, but it would
|
||||
// also change the semantics of a timer: Right now, ScummVM timers
|
||||
// *never* run in parallel, due to the way they are implemented. If we
|
||||
// switched to SDL_AddTimer, each timer might run in a separate thread.
|
||||
// Unfortunately, not all our code is prepared for that, so we can't just
|
||||
// switch. But it's a long term goal to do just that!
|
||||
_timer = new DefaultTimerManager();
|
||||
setTimerCallback(&timer_handler, 10);
|
||||
_timerID = SDL_AddTimer(10, &timer_handler, _timer);
|
||||
}
|
||||
|
||||
OSystem::initBackend();
|
||||
@ -240,10 +247,17 @@ OSystem_SDL::OSystem_SDL()
|
||||
}
|
||||
|
||||
OSystem_SDL::~OSystem_SDL() {
|
||||
SDL_RemoveTimer(_timerID);
|
||||
SDL_CloseAudio();
|
||||
|
||||
free(_dirtyChecksums);
|
||||
free(_currentPalette);
|
||||
free(_cursorPalette);
|
||||
free(_mouseData);
|
||||
|
||||
delete _savefile;
|
||||
delete _mixer;
|
||||
delete _timer;
|
||||
}
|
||||
|
||||
uint32 OSystem_SDL::getMillis() {
|
||||
@ -254,10 +268,6 @@ void OSystem_SDL::delayMillis(uint msecs) {
|
||||
SDL_Delay(msecs);
|
||||
}
|
||||
|
||||
void OSystem_SDL::setTimerCallback(TimerProc callback, int timer) {
|
||||
SDL_SetTimer(timer, (SDL_TimerCallback) callback);
|
||||
}
|
||||
|
||||
Common::TimerManager *OSystem_SDL::getTimerManager() {
|
||||
assert(_timer);
|
||||
return _timer;
|
||||
@ -445,10 +455,6 @@ bool OSystem_SDL::setSoundCallback(SoundProc proc, void *param) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void OSystem_SDL::clearSoundCallback() {
|
||||
SDL_CloseAudio();
|
||||
}
|
||||
|
||||
int OSystem_SDL::getOutputSampleRate() const {
|
||||
return _samplesPerSec;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user