From 4611b12c0a84ec528f9f020dc85bf4e9a0108c82 Mon Sep 17 00:00:00 2001
From: Max Horn
Date: Sat, 5 Jul 2003 15:17:46 +0000
Subject: updated backends to use type MutexRef

svn-id: r8776
---
 backends/sdl/sdl-common.cpp | 15 ++++++++-------
 backends/sdl/sdl-common.h   | 21 +++++----------------
 2 files changed, 13 insertions(+), 23 deletions(-)

(limited to 'backends/sdl')

diff --git a/backends/sdl/sdl-common.cpp b/backends/sdl/sdl-common.cpp
index fd720cd9b9..28e87db04b 100644
--- a/backends/sdl/sdl-common.cpp
+++ b/backends/sdl/sdl-common.cpp
@@ -23,6 +23,7 @@
 #include "sound/mididrv.h"
 #include "common/scaler.h"
 #include "common/engine.h"	// Only #included for error() and warning()
+#include "common/util.h"
 
 #include "scummvm.xpm"
 
@@ -63,7 +64,7 @@ void OSystem_SDL_Common::init_intern(int gfx_mode, bool full_screen, bool aspect
 		error("Could not initialize SDL: %s.\n", SDL_GetError());
 	}
 
-	_graphicsMutex = SDL_CreateMutex();
+	_graphicsMutex = create_mutex();
 
 	SDL_ShowCursor(SDL_DISABLE);
 	
@@ -113,7 +114,7 @@ OSystem_SDL_Common::~OSystem_SDL_Common() {
 		free(_dirty_checksums);
 	free(_currentPalette);
 	free(_mouseBackup);
-	SDL_DestroyMutex(_graphicsMutex);
+	delete_mutex(_graphicsMutex);
 
 	SDL_ShowCursor(SDL_ENABLE);
 #ifdef MACOSX
@@ -1192,19 +1193,19 @@ void OSystem_SDL_Common::setup_icon() {
 	SDL_FreeSurface(sdl_surf);
 }
 
-void *OSystem_SDL_Common::create_mutex(void) {
-	return (void *) SDL_CreateMutex();
+OSystem::MutexRef OSystem_SDL_Common::create_mutex(void) {
+	return (MutexRef) SDL_CreateMutex();
 }
 
-void OSystem_SDL_Common::lock_mutex(void *mutex) {
+void OSystem_SDL_Common::lock_mutex(MutexRef mutex) {
 	SDL_mutexP((SDL_mutex *) mutex);
 }
 
-void OSystem_SDL_Common::unlock_mutex(void *mutex) {
+void OSystem_SDL_Common::unlock_mutex(MutexRef mutex) {
 	SDL_mutexV((SDL_mutex *) mutex);
 }
 
-void OSystem_SDL_Common::delete_mutex(void *mutex) {
+void OSystem_SDL_Common::delete_mutex(MutexRef mutex) {
 	SDL_DestroyMutex((SDL_mutex *) mutex);
 }
 
diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h
index da878153d4..4a2a8d0087 100644
--- a/backends/sdl/sdl-common.h
+++ b/backends/sdl/sdl-common.h
@@ -105,10 +105,10 @@ public:
 	void set_timer(int timer, int (*callback)(int));
 
 	// Mutex handling
-	void *create_mutex();
-	void lock_mutex(void *mutex);
-	void unlock_mutex(void *mutex);
-	void delete_mutex(void *mutex);
+	MutexRef create_mutex();
+	void lock_mutex(MutexRef mutex);
+	void unlock_mutex(MutexRef mutex);
+	void delete_mutex(MutexRef mutex);
 
 	// Overlay
 	virtual void show_overlay();
@@ -208,7 +208,7 @@ protected:
 	
 	// Mutex that prevents multiple threads interferring with each other
 	// when accessing the screen.
-	SDL_mutex *_graphicsMutex;
+	MutexRef _graphicsMutex;
 
 
 	void add_dirty_rgn_auto(const byte *buf);
@@ -229,15 +229,4 @@ protected:
 	void init_joystick() { _joystick = SDL_JoystickOpen(0); }
 };
 
-// Auxillary class to (un)lock a mutex on the stack
-class StackLock {
-	SDL_mutex *_mutex;
-public:
-	StackLock(SDL_mutex *mutex) : _mutex(mutex) { lock(); }
-	~StackLock() { unlock(); }
-	void lock() { SDL_mutexP(_mutex); }
-	void unlock() { SDL_mutexV(_mutex); }
-};
-
-
 #endif
-- 
cgit v1.2.3