diff options
author | althekiller <althekiller@svn> | 2010-01-18 04:32:30 +0000 |
---|---|---|
committer | althekiller <althekiller@svn> | 2010-01-18 04:32:30 +0000 |
commit | afacd3f18fb63004c21dbc07a348c6c9c30fd83b (patch) | |
tree | e15fcb11a6a3f48c60a62fab3a7644ee78d26220 | |
parent | 9524b461e1cee7c29d8ceeaacd2642fb6c36b279 (diff) |
changed: Replace SDL_semaphore with our own abstraction
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@26968 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
-rw-r--r-- | xbmc/cores/paplayer/SIDCodec/Makefile.in | 2 | ||||
-rw-r--r-- | xbmc/linux/XHandle.cpp | 12 | ||||
-rw-r--r-- | xbmc/linux/XHandle.h | 3 | ||||
-rw-r--r-- | xbmc/linux/XSyncUtils.cpp | 12 | ||||
-rw-r--r-- | xbmc/utils/Makefile | 5 | ||||
-rw-r--r-- | xbmc/utils/Semaphore.cpp | 6 |
6 files changed, 23 insertions, 17 deletions
diff --git a/xbmc/cores/paplayer/SIDCodec/Makefile.in b/xbmc/cores/paplayer/SIDCodec/Makefile.in index fd77476c18..a434b95110 100644 --- a/xbmc/cores/paplayer/SIDCodec/Makefile.in +++ b/xbmc/cores/paplayer/SIDCodec/Makefile.in @@ -1,6 +1,6 @@ ARCH=@ARCH@ -CFLAGS +=-D_LINUX -DHAVE_UNIX -DHAVE_STRCASECMP -DHAVE_STRNCASECMP -DHAVE_IOS_OPENMODE -fPIC -Ilibsidplay/win/VC -Ibuilders/resid-builder/include/sidplay/builders -Ilibsidplay/include/sidplay -Iresid -Ilibsidplay/include -I../../../linux -I../../../ -I../../../../guilib/ -fPIC +CFLAGS +=-D_LINUX -DHAVE_UNIX -DHAVE_STRCASECMP -DHAVE_STRNCASECMP -DHAVE_IOS_OPENMODE -fPIC -Ilibsidplay/win/VC -Ibuilders/resid-builder/include/sidplay/builders -Ilibsidplay/include/sidplay -Iresid -Ilibsidplay/include -I../../../linux -I../../../utils -I../../../ -I../../../../guilib/ -fPIC CXXFLAGS += $(CFLAGS) ifeq ($(ARCH), powerpc-osx) BUNDLE1_O=-lbundle1.o -L/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/ -lgcc diff --git a/xbmc/linux/XHandle.cpp b/xbmc/linux/XHandle.cpp index 5a314f6281..59f7c1c4da 100644 --- a/xbmc/linux/XHandle.cpp +++ b/xbmc/linux/XHandle.cpp @@ -47,8 +47,8 @@ CXHandle::CXHandle(const CXHandle &src) CLog::Log(LOGWARNING,"%s, copy handle.", __FUNCTION__); Init(); - if (src.m_hSem) - m_hSem = SDL_CreateSemaphore(SDL_SemValue(src.m_hSem)); + if (src.m_pSem) + m_pSem = new CSemaphore(*src.m_pSem); if (m_threadValid) { @@ -83,10 +83,8 @@ CXHandle::~CXHandle() CLog::Log(LOGERROR,"%s, destroying handle with ref count %d", __FUNCTION__, m_nRefCount); assert(false); } - - if (m_hSem) { - SDL_DestroySemaphore(m_hSem); - } + + delete m_pSem; if (m_hMutex) { SDL_DestroyMutex(m_hMutex); @@ -113,7 +111,7 @@ CXHandle::~CXHandle() void CXHandle::Init() { fd=0; - m_hSem=NULL; + m_pSem=NULL; m_hMutex=NULL; m_threadValid=false; m_hCond=NULL; diff --git a/xbmc/linux/XHandle.h b/xbmc/linux/XHandle.h index db6fcc1d7d..85799e2a15 100644 --- a/xbmc/linux/XHandle.h +++ b/xbmc/linux/XHandle.h @@ -30,6 +30,7 @@ #include "PlatformDefs.h" #include "XHandlePublic.h" +#include "Semaphore.h" #include <list> struct CXHandle { @@ -46,7 +47,7 @@ public: inline HandleType GetType() { return m_type; } void ChangeType(HandleType newType); - SDL_sem *m_hSem; + CSemaphore *m_pSem; ThreadIdentifier m_hThread; bool m_threadValid; SDL_cond *m_hCond; diff --git a/xbmc/linux/XSyncUtils.cpp b/xbmc/linux/XSyncUtils.cpp index cfad28cfa5..f110ecacd1 100644 --- a/xbmc/linux/XSyncUtils.cpp +++ b/xbmc/linux/XSyncUtils.cpp @@ -53,7 +53,7 @@ bool InitializeRecursiveMutex(HANDLE hMutex, BOOL bInitialOwner) { // we use semaphores instead of the mutex because in SDL we CANT wait for a mutex // to lock with timeout. - hMutex->m_hSem = SDL_CreateSemaphore(bInitialOwner?0:1); + hMutex->m_pSem = new CSemaphore(bInitialOwner?0:1); hMutex->m_hMutex = SDL_CreateMutex(); hMutex->ChangeType(CXHandle::HND_MUTEX); @@ -66,14 +66,14 @@ bool InitializeRecursiveMutex(HANDLE hMutex, BOOL bInitialOwner) { } bool DestroyRecursiveMutex(HANDLE hMutex) { - if (hMutex == NULL || hMutex->m_hMutex == NULL || hMutex->m_hSem == NULL) + if (hMutex == NULL || hMutex->m_hMutex == NULL || hMutex->m_pSem == NULL) return false; - SDL_DestroySemaphore(hMutex->m_hSem); + delete hMutex->m_pSem; SDL_DestroyMutex(hMutex->m_hMutex); hMutex->m_hMutex = NULL; - hMutex->m_hSem = NULL; + hMutex->m_pSem = NULL; return true; } @@ -87,7 +87,7 @@ HANDLE WINAPI CreateMutex( LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInit } bool WINAPI ReleaseMutex( HANDLE hMutex ) { - if (hMutex == NULL || hMutex->m_hSem == NULL || hMutex->m_hMutex == NULL) + if (hMutex == NULL || hMutex->m_pSem == NULL || hMutex->m_hMutex == NULL) return false; BOOL bOk = false; @@ -97,7 +97,7 @@ bool WINAPI ReleaseMutex( HANDLE hMutex ) { bOk = true; if (--hMutex->RecursionCount == 0) { hMutex->OwningThread = 0; - SDL_SemPost(hMutex->m_hSem); + hMutex->m_pSem->Post(); } } SDL_mutexV(hMutex->m_hMutex); diff --git a/xbmc/utils/Makefile b/xbmc/utils/Makefile index d208da2501..77a609072c 100644 --- a/xbmc/utils/Makefile +++ b/xbmc/utils/Makefile @@ -1,4 +1,4 @@ -INCLUDES=-I. -I.. -I../../ -I../linux -I../cores -I../../guilib +INCLUDES=-I. -I.. -I../../ -I../linux -I../cores -I../../guilib -I../posix SRCS=AlarmClock.cpp \ Archive.cpp \ @@ -59,7 +59,8 @@ SRCS=AlarmClock.cpp \ Teletext.cpp \ fastmemcpy.cpp \ PasswordManager.cpp \ - AliasShortcutUtils.cpp + AliasShortcutUtils.cpp \ + Semaphore.cpp LIB=utils.a diff --git a/xbmc/utils/Semaphore.cpp b/xbmc/utils/Semaphore.cpp index 1407ae88cd..0217a602a2 100644 --- a/xbmc/utils/Semaphore.cpp +++ b/xbmc/utils/Semaphore.cpp @@ -2,6 +2,8 @@ #include "Semaphore.h" #ifdef __linux__ #include "SemaphorePOSIX.h" +#elif defined(__APPLE__) +#include "SemaphoreDarwin.h" #endif CSemaphore::CSemaphore(uint32_t initialCount/*=1*/) @@ -9,6 +11,8 @@ CSemaphore::CSemaphore(uint32_t initialCount/*=1*/) { #ifdef _SEMAPHORE_H m_pSemaphore = new CSemaphorePOSIX(initialCount); +#elif defined(_BSD_SEMAPHORE_H) + m_pSemaphore = new CSemaphoreDarwin(initialCount); #else #error No supported semaphore implementation available #endif @@ -19,6 +23,8 @@ CSemaphore::CSemaphore(const CSemaphore& sem) { #ifdef _SEMAPHORE_H m_pSemaphore = new CSemaphorePOSIX(sem.GetCount()); +#elif defined(_BSD_SEMAPHORE_H) + m_pSemaphore = new CSemaphoreDarwin(initialCount); #else #error No supported semaphore implementation available #endif |