aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorS. Davilla <davilla@4pi.com>2011-03-10 21:00:03 -0500
committerS. Davilla <davilla@4pi.com>2011-03-14 18:02:09 -0400
commit9f68aa101f4b2ae1e1eb77e4acf53ecbe0d4dc39 (patch)
treeee222a7d4ef6a96940c0cf1d1c378126c36c216c
parentc4175e43ee3f22e353af1faf07a26978c35da37c (diff)
[ios] prep, exclusion of SDL which means replacements for SDL_cond, SDL_mutex and SDL event handling, ios only
-rw-r--r--xbmc/Application.cpp76
-rw-r--r--xbmc/Application.h10
-rw-r--r--xbmc/input/ButtonTranslator.cpp8
-rw-r--r--xbmc/input/SDLJoystick.h4
-rw-r--r--xbmc/linux/XHandle.cpp2
-rw-r--r--xbmc/linux/XHandle.h5
-rw-r--r--xbmc/linux/XSyncUtils.cpp13
-rw-r--r--xbmc/system.h35
-rw-r--r--xbmc/threads/XBMC_cond.cpp151
-rw-r--r--xbmc/threads/XBMC_cond.h72
-rw-r--r--xbmc/threads/XBMC_mutex.cpp202
-rw-r--r--xbmc/threads/XBMC_mutex.h85
-rw-r--r--xbmc/utils/PerformanceSample.cpp1
-rw-r--r--xbmc/video/Teletext.cpp7
-rw-r--r--xbmc/windowing/WinEvents.h5
-rw-r--r--xbmc/windowing/WinEventsSDL.h5
-rw-r--r--xbmc/windowing/osx/WinEventsIOS.h40
-rw-r--r--xbmc/windowing/osx/WinEventsIOS.mm91
18 files changed, 757 insertions, 55 deletions
diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp
index 4ccc50eba4..49c96263f9 100644
--- a/xbmc/Application.cpp
+++ b/xbmc/Application.cpp
@@ -236,8 +236,12 @@
#include "windowing/X11/XRandR.h"
#endif
#ifdef __APPLE__
+#if !defined(__arm__)
#include "CocoaInterface.h"
#include "XBMCHelper.h"
+#else
+#include "iOSUtils.h"
+#endif
#endif
#ifdef HAS_DVD_DRIVE
@@ -320,7 +324,7 @@ CApplication::CApplication(void) : m_itemCurrentFile(new CFileItem), m_progressT
#endif
m_currentStack = new CFileItemList;
-#ifdef HAS_SDL
+#if defined(HAS_SDL) || (defined(__APPLE__) && defined(__arm__))
m_frameCount = 0;
m_frameMutex = SDL_CreateMutex();
m_frameCond = SDL_CreateCond();
@@ -343,7 +347,7 @@ CApplication::~CApplication(void)
delete m_pKaraokeMgr;
#endif
-#ifdef HAS_SDL
+#if defined(HAS_SDL) || (defined(__APPLE__) && defined(__arm__))
if (m_frameMutex)
SDL_DestroyMutex(m_frameMutex);
@@ -433,7 +437,7 @@ void CApplication::Preflight()
#endif
// run any platform preflight scripts.
-#ifdef __APPLE__
+#if defined(__APPLE__) && !defined(__arm__)
CStdString install_path;
CUtil::GetHomePath(install_path);
@@ -654,7 +658,7 @@ bool CApplication::Create()
g_Joystick.Initialize();
#endif
-#ifdef __APPLE__
+#if defined(__APPLE__) && !defined(__arm__)
// Configure and possible manually start the helper.
XBMCHelper::GetInstance().Configure();
#endif
@@ -851,30 +855,46 @@ bool CApplication::InitDirectoriesOSX()
CUtil::GetHomePath(xbmcPath);
setenv("XBMC_HOME", xbmcPath.c_str(), 0);
+#if defined(__arm__)
+ CStdString fontconfigPath;
+ fontconfigPath = xbmcPath + "/system/players/dvdplayer/etc/fonts/fonts.conf";
+ setenv("FONTCONFIG_FILE", fontconfigPath.c_str(), 0);
+#endif
+
// setup path to our internal dylibs so loader can find them
CStdString frameworksPath = CUtil::GetFrameworksPath();
CSpecialProtocol::SetXBMCFrameworksPath(frameworksPath);
-
+
// OSX always runs with m_bPlatformDirectories == true
if (m_bPlatformDirectories)
{
// map our special drives
CSpecialProtocol::SetXBMCBinPath(xbmcPath);
CSpecialProtocol::SetXBMCPath(xbmcPath);
- CSpecialProtocol::SetHomePath(userHome + "/Library/Application Support/XBMC");
- CSpecialProtocol::SetMasterProfilePath(userHome + "/Library/Application Support/XBMC/userdata");
-
-#ifdef __APPLE__
- CStdString strTempPath = URIUtils::AddFileToFolder(userHome, ".xbmc/");
- CDirectory::Create(strTempPath);
-#endif
-
- strTempPath = URIUtils::AddFileToFolder(userHome, ".xbmc/temp");
+ #if defined(__arm__)
+ CSpecialProtocol::SetHomePath(userHome + "/Library/Preferences/XBMC");
+ CSpecialProtocol::SetMasterProfilePath(userHome + "/Library/Preferences/XBMC/userdata");
+ #else
+ CSpecialProtocol::SetHomePath(userHome + "/Library/Application Support/XBMC");
+ CSpecialProtocol::SetMasterProfilePath(userHome + "/Library/Application Support/XBMC/userdata");
+ #endif
+
+ // location for temp files
+ #if defined(__arm__)
+ CStdString strTempPath = URIUtils::AddFileToFolder(userHome, "Library/Preferences/XBMC/temp");
+ #else
+ CStdString strTempPath = URIUtils::AddFileToFolder(userHome, ".xbmc/");
+ CDirectory::Create(strTempPath);
+ strTempPath = URIUtils::AddFileToFolder(userHome, ".xbmc/temp");
+ #endif
CSpecialProtocol::SetTempPath(strTempPath);
-#ifdef __APPLE__
- strTempPath = userHome + "/Library/Logs";
-#endif
+ // xbmc.log file location
+ #if defined(__arm__)
+ strTempPath = userHome + "/Library/Preferences";
+ #else
+ strTempPath = userHome + "/Library/Logs";
+ #endif
URIUtils::AddSlashAtEnd(strTempPath);
g_settings.m_logFolder = strTempPath;
@@ -1153,7 +1173,7 @@ bool CApplication::Initialize()
m_slowTimer.StartZero();
-#ifdef __APPLE__
+#if defined(__APPLE__) && !defined(__arm__)
XBMCHelper::GetInstance().CaptureAllInput();
#endif
#if defined(HAVE_LIBCRYSTALHD)
@@ -1879,7 +1899,7 @@ void CApplication::RenderScreenSaver()
bool CApplication::WaitFrame(unsigned int timeout)
{
bool done = false;
-#ifdef HAS_SDL
+#if defined(HAS_SDL) || (defined(__APPLE__) && defined(__arm__))
// Wait for all other frames to be presented
SDL_mutexP(m_frameMutex);
//wait until event is set, but modify remaining time
@@ -1917,7 +1937,7 @@ bool CApplication::WaitFrame(unsigned int timeout)
void CApplication::NewFrame()
{
-#ifdef HAS_SDL
+#if defined(HAS_SDL) || (defined(__APPLE__) && defined(__arm__))
// We just posted another frame. Keep track and notify.
SDL_mutexP(m_frameMutex);
m_frameCount++;
@@ -1955,7 +1975,7 @@ void CApplication::Render()
m_bPresentFrame = false;
if (!extPlayerActive && g_graphicsContext.IsFullScreenVideo() && !IsPaused())
{
-#ifdef HAS_SDL
+#if defined(HAS_SDL) || (defined(__APPLE__) && defined(__arm__))
SDL_mutexP(m_frameMutex);
//wait until event is set, but modify remaining time
@@ -2060,7 +2080,7 @@ void CApplication::Render()
g_renderManager.UpdateResolution();
g_renderManager.ManageCaptures();
-#ifdef HAS_SDL
+#if defined(HAS_SDL) || (defined(__APPLE__) && defined(__arm__))
SDL_mutexP(m_frameMutex);
if(m_frameCount > 0 && decrement)
m_frameCount--;
@@ -3263,7 +3283,7 @@ void CApplication::Stop()
StopServices();
//Sleep(5000);
-#ifdef __APPLE__
+#if defined(__APPLE__) && !defined(__arm__)
XBMCHelper::GetInstance().ReleaseAllInput();
#endif
@@ -3303,7 +3323,7 @@ void CApplication::Stop()
CLog::Log(LOGNOTICE, "unload skin");
UnloadSkin();
-#ifdef __APPLE__
+#if defined(__APPLE__) && !defined(__arm__)
if (XBMCHelper::GetInstance().IsAlwaysOn() == false)
XBMCHelper::GetInstance().Stop();
#endif
@@ -4130,7 +4150,7 @@ void CApplication::ResetScreenSaver()
void CApplication::ResetScreenSaverTimer()
{
-#ifdef __APPLE__
+#if defined(__APPLE__) && !defined(__arm__)
Cocoa_UpdateSystemActivity();
#endif
m_screenSaverTimer.StartZero();
@@ -4681,7 +4701,7 @@ void CApplication::ProcessSlow()
{
g_powerManager.ProcessEvents();
-#if defined(__APPLE__)
+#if defined(__APPLE__) && !defined(__arm__)
// There is an issue on OS X that several system services ask the cursor to become visible
// during their startup routines. Given that we can't control this, we hack it in by
// forcing the
@@ -5157,7 +5177,7 @@ bool CApplication::SwitchToFullScreen()
// See if we're playing a video, and are in GUI mode
if ( IsPlayingVideo() && g_windowManager.GetActiveWindow() != WINDOW_FULLSCREEN_VIDEO)
{
-#ifdef HAS_SDL
+#if defined(HAS_SDL) || (defined(__APPLE__) && defined(__arm__))
// Reset frame count so that timing is FPS will be correct.
SDL_mutexP(m_frameMutex);
m_frameCount = 0;
@@ -5334,7 +5354,7 @@ bool CApplication::IsCurrentThread() const
bool CApplication::IsPresentFrame()
{
-#ifdef HAS_SDL // TODO:DIRECTX
+#if defined(HAS_SDL) || (defined(__APPLE__) && defined(__arm__)) //TODO:DIRECTX
SDL_mutexP(m_frameMutex);
bool ret = m_bPresentFrame;
SDL_mutexV(m_frameMutex);
diff --git a/xbmc/Application.h b/xbmc/Application.h
index 6fa46225d2..522b6c3eb6 100644
--- a/xbmc/Application.h
+++ b/xbmc/Application.h
@@ -69,9 +69,14 @@ namespace ADDON
#include "network/WebServer.h"
#endif
+#if (defined(__APPLE__) && defined(__arm__))
+#include "threads/XBMC_cond.h"
+#include "threads/XBMC_mutex.h"
+#else
#ifdef HAS_SDL
#include <SDL/SDL_mutex.h>
#endif
+#endif
class CKaraokeLyricsManager;
class CApplicationMessenger;
@@ -301,6 +306,9 @@ protected:
bool m_skinReloading; // if true we disallow LoadSkin until ReloadSkin is called
friend class CApplicationMessenger;
+#if defined(__APPLE__) && defined(__arm__)
+ friend class CWinEventsIOS;
+#endif
// screensaver
bool m_bScreenSave;
ADDON::AddonPtr m_screenSaver;
@@ -350,7 +358,7 @@ protected:
CGUITextLayout *m_debugLayout;
-#ifdef HAS_SDL
+#if defined(HAS_SDL) || (defined(__APPLE__) && defined(__arm__))
int m_frameCount;
SDL_mutex* m_frameMutex;
SDL_cond* m_frameCond;
diff --git a/xbmc/input/ButtonTranslator.cpp b/xbmc/input/ButtonTranslator.cpp
index 5fad442cee..d6d1a1eaa7 100644
--- a/xbmc/input/ButtonTranslator.cpp
+++ b/xbmc/input/ButtonTranslator.cpp
@@ -582,13 +582,13 @@ void CButtonTranslator::MapJoystickActions(int windowID, TiXmlNode *pJoystick)
{
uint32_t hatID = id|0xFFF00000;
if (position.compare("up") == 0)
- hatMap[(SDL_HAT_UP<<16)|hatID] = string(szAction);
+ hatMap[(JACTIVE_HAT_UP<<16)|hatID] = string(szAction);
else if (position.compare("down") == 0)
- hatMap[(SDL_HAT_DOWN<<16)|hatID] = string(szAction);
+ hatMap[(JACTIVE_HAT_DOWN<<16)|hatID] = string(szAction);
else if (position.compare("right") == 0)
- hatMap[(SDL_HAT_RIGHT<<16)|hatID] = string(szAction);
+ hatMap[(JACTIVE_HAT_RIGHT<<16)|hatID] = string(szAction);
else if (position.compare("left") == 0)
- hatMap[(SDL_HAT_LEFT<<16)|hatID] = string(szAction);
+ hatMap[(JACTIVE_HAT_LEFT<<16)|hatID] = string(szAction);
else
CLog::Log(LOGERROR, "Error in joystick map, invalid position specified %s for axis %d", position.c_str(), id);
}
diff --git a/xbmc/input/SDLJoystick.h b/xbmc/input/SDLJoystick.h
index b60f1b62c9..a08364f5ce 100644
--- a/xbmc/input/SDLJoystick.h
+++ b/xbmc/input/SDLJoystick.h
@@ -30,6 +30,10 @@
#define JACTIVE_AXIS 0x00000002
#define JACTIVE_HAT 0x00000004
#define JACTIVE_NONE 0x00000000
+#define JACTIVE_HAT_UP 0x01
+#define JACTIVE_HAT_RIGHT 0x02
+#define JACTIVE_HAT_DOWN 0x04
+#define JACTIVE_HAT_LEFT 0x08
#ifdef HAS_SDL_JOYSTICK
diff --git a/xbmc/linux/XHandle.cpp b/xbmc/linux/XHandle.cpp
index 59f7c1c4da..0cf73e93bf 100644
--- a/xbmc/linux/XHandle.cpp
+++ b/xbmc/linux/XHandle.cpp
@@ -19,7 +19,9 @@
*
*/
+#if !(defined(__APPLE__) && defined(__arm__))
#include <SDL/SDL.h>
+#endif
#include "XHandle.h"
#include "XThreadUtils.h"
diff --git a/xbmc/linux/XHandle.h b/xbmc/linux/XHandle.h
index e4e5a6f75a..9b4f3d05d8 100644
--- a/xbmc/linux/XHandle.h
+++ b/xbmc/linux/XHandle.h
@@ -25,7 +25,12 @@
#ifndef _WIN32
#include "utils/StdString.h"
+#if defined(__APPLE__) && defined(__arm__)
+#include <threads/XBMC_cond.h>
+#include <threads/XBMC_mutex.h>
+#else
#include <SDL/SDL_mutex.h>
+#endif
#include <pthread.h>
#include "PlatformDefs.h"
diff --git a/xbmc/linux/XSyncUtils.cpp b/xbmc/linux/XSyncUtils.cpp
index 7837a0a580..253d14f5b4 100644
--- a/xbmc/linux/XSyncUtils.cpp
+++ b/xbmc/linux/XSyncUtils.cpp
@@ -25,11 +25,16 @@
#include "XHandle.h"
#include "XEventUtils.h"
-#ifdef __APPLE__
-#include <mach/mach.h>
-#include <SDL/SDL.h>
+#if (defined(__APPLE__) && defined(__arm__))
+ #include <threads/XBMC_cond.h>
+ #include <threads/XBMC_mutex.h>
#else
-#include <SDL.h>
+ #ifdef __APPLE__
+ #include <mach/mach.h>
+ #include <SDL/SDL.h>
+ #else
+ #include <SDL.h>
+ #endif
#endif
#ifdef _LINUX
diff --git a/xbmc/system.h b/xbmc/system.h
index d3444e63b3..1ffe6f049a 100644
--- a/xbmc/system.h
+++ b/xbmc/system.h
@@ -101,12 +101,19 @@
*****************/
#ifdef __APPLE__
-#define HAS_ZEROCONF
-#define HAS_GL
-#define HAS_LINUX_NETWORK
-#define HAS_SDL_AUDIO
-#define HAS_SDL_OPENGL
-#define HAS_SDL_WIN_EVENTS
+ #if defined(__arm__)
+ #undef HAS_GL
+ #undef HAS_SDL
+ #define HAVE_LIBEGL
+ #define HAVE_LIBGLESV2
+ #else
+ #define HAS_GL
+ #define HAS_SDL_AUDIO
+ #define HAS_SDL_OPENGL
+ #define HAS_SDL_WIN_EVENTS
+ #endif
+ #define HAS_ZEROCONF
+ #define HAS_LINUX_NETWORK
#endif
/*****************
@@ -234,15 +241,13 @@
#endif
#if HAS_GLES == 2
-#ifdef _ARMEL // PowerVR SGX Header
-// not sure about this one tg2 (arm) does not have gl2extimg.h
-//#include <GLES2/gl2extimg.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#else
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#endif
+ #if defined(__APPLE__)
+ #include <OpenGLES/ES2/gl.h>
+ #include <OpenGLES/ES2/glext.h>
+ #else
+ #include <GLES2/gl2.h>
+ #include <GLES2/gl2ext.h>
+ #endif
#endif
#ifdef HAS_DVD_DRIVE
diff --git a/xbmc/threads/XBMC_cond.cpp b/xbmc/threads/XBMC_cond.cpp
new file mode 100644
index 0000000000..c3a3906b83
--- /dev/null
+++ b/xbmc/threads/XBMC_cond.cpp
@@ -0,0 +1,151 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#if defined(__APPLE__) && defined(__arm__)
+#include <sys/time.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <pthread.h>
+
+#include "XBMC_cond.h"
+#include "log.h"
+
+/* Create a condition variable */
+SDL_cond * SDL_CreateCond(void)
+{
+ SDL_cond *cond;
+
+ cond = (SDL_cond *) malloc(sizeof(SDL_cond));
+ if ( cond ) {
+ if ( pthread_cond_init(&cond->cond, NULL) < 0 ) {
+ CLog::Log(LOGERROR, "pthread_cond_init() failed");
+ free(cond);
+ cond = NULL;
+ }
+ }
+ return(cond);
+}
+
+/* Destroy a condition variable */
+void SDL_DestroyCond(SDL_cond *cond)
+{
+ if ( cond ) {
+ pthread_cond_destroy(&cond->cond);
+ free(cond);
+ }
+}
+
+/* Restart one of the threads that are waiting on the condition variable */
+int SDL_CondSignal(SDL_cond *cond)
+{
+ int retval;
+
+ if ( ! cond ) {
+ CLog::Log(LOGERROR, "Passed a NULL condition variable");
+ return -1;
+ }
+
+ retval = 0;
+ if ( pthread_cond_signal(&cond->cond) != 0 ) {
+ CLog::Log(LOGERROR, "pthread_cond_signal() failed");
+ retval = -1;
+ }
+ return retval;
+}
+
+/* Restart all threads that are waiting on the condition variable */
+int SDL_CondBroadcast(SDL_cond *cond)
+{
+ int retval;
+
+ if ( ! cond ) {
+ CLog::Log(LOGERROR, "Passed a NULL condition variable");
+ return -1;
+ }
+
+ retval = 0;
+ if ( pthread_cond_broadcast(&cond->cond) != 0 ) {
+ CLog::Log(LOGERROR, "pthread_cond_broadcast() failed");
+ retval = -1;
+ }
+ return retval;
+}
+
+int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, uint32_t ms)
+{
+ int retval;
+ struct timeval delta;
+ struct timespec abstime;
+
+ if ( ! cond ) {
+ CLog::Log(LOGERROR, "Passed a NULL condition variable");
+ return -1;
+ }
+
+ gettimeofday(&delta, NULL);
+
+ abstime.tv_sec = delta.tv_sec + (ms/1000);
+ abstime.tv_nsec = (delta.tv_usec + (ms%1000) * 1000) * 1000;
+ if ( abstime.tv_nsec > 1000000000 ) {
+ abstime.tv_sec += 1;
+ abstime.tv_nsec -= 1000000000;
+ }
+
+ tryagain:
+ retval = pthread_cond_timedwait(&cond->cond, &mutex->id, &abstime);
+ switch (retval) {
+ case EINTR:
+ goto tryagain;
+ break;
+ case ETIMEDOUT:
+ retval = SDL_MUTEX_TIMEDOUT;
+ break;
+ case 0:
+ break;
+ default:
+ CLog::Log(LOGERROR, "pthread_cond_timedwait() failed");
+ retval = -1;
+ break;
+ }
+ return retval;
+}
+
+/* Wait on the condition variable, unlocking the provided mutex.
+ The mutex must be locked before entering this function!
+ */
+int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex)
+{
+ int retval;
+
+ if ( ! cond ) {
+ CLog::Log(LOGERROR, "Passed a NULL condition variable");
+ return -1;
+ }
+
+ retval = 0;
+ if ( pthread_cond_wait(&cond->cond, &mutex->id) != 0 ) {
+ CLog::Log(LOGERROR, "pthread_cond_wait() failed");
+ retval = -1;
+ }
+ return retval;
+}
+#endif \ No newline at end of file
diff --git a/xbmc/threads/XBMC_cond.h b/xbmc/threads/XBMC_cond.h
new file mode 100644
index 0000000000..9293725566
--- /dev/null
+++ b/xbmc/threads/XBMC_cond.h
@@ -0,0 +1,72 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+
+#if defined(__APPLE__) && defined(__arm__)
+#ifndef _SDL_cond_h
+#define _SDL_cond_h
+
+#include <stdint.h>
+#include "XBMC_mutex.h"
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* Condition variable functions */
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* The SDL condition variable structure, defined in SDL_cond.c */
+typedef struct SDL_cond
+{
+ pthread_cond_t cond;
+} SDL_cond;
+
+/* Create a condition variable */
+SDL_cond *SDL_CreateCond(void);
+
+/* Destroy a condition variable */
+void SDL_DestroyCond(SDL_cond *cond);
+
+/* Restart one of the threads that are waiting on the condition variable,
+ returns 0 or -1 on error.
+ */
+int SDL_CondSignal(SDL_cond *cond);
+
+/* Restart all threads that are waiting on the condition variable,
+ returns 0 or -1 on error.
+ */
+int SDL_CondBroadcast(SDL_cond *cond);
+
+/* Wait on the condition variable, unlocking the provided mutex.
+ The mutex must be locked before entering this function!
+ The mutex is re-locked once the condition variable is signaled.
+ Returns 0 when it is signaled, or -1 on error.
+ */
+int SDL_CondWait(SDL_cond *cond, SDL_mutex *mut);
+
+/* Waits for at most 'ms' milliseconds, and returns 0 if the condition
+ variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not
+ signaled in the allotted time, and -1 on error.
+ On some platforms this function is implemented by looping with a delay
+ of 1 ms, and so should be avoided if possible.
+*/
+int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, uint32_t ms);
+
+#endif /* _SDL_cond_h */
+#endif
diff --git a/xbmc/threads/XBMC_mutex.cpp b/xbmc/threads/XBMC_mutex.cpp
new file mode 100644
index 0000000000..5e8d26839e
--- /dev/null
+++ b/xbmc/threads/XBMC_mutex.cpp
@@ -0,0 +1,202 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+
+#if defined(__APPLE__) && defined(__arm__)
+#if defined(_WIN32)
+ #include <windows.h>
+#else
+ #include <stdlib.h>
+#endif
+
+#include "XBMC_mutex.h"
+#include "log.h"
+
+SDL_mutex *SDL_CreateMutex (void)
+{
+#if defined(_WIN32)
+ SDL_mutex *mutex;
+
+ /* Allocate mutex memory */
+ mutex = (SDL_mutex *)malloc(sizeof(*mutex));
+ if ( mutex ) {
+ /* Create the mutex, with initial value signaled */
+ mutex->id = CreateMutex(NULL, FALSE, NULL);
+ if ( ! mutex->id ) {
+ CLog::Log(LOGERROR, "Couldn't create mutex");
+ free(mutex);
+ mutex = NULL;
+ }
+ } else {
+ CLog::Log(LOGERROR, "OutOfMemory");
+ }
+ return(mutex);
+#else
+ SDL_mutex *mutex;
+ pthread_mutexattr_t attr;
+
+ /* Allocate the structure */
+ mutex = (SDL_mutex *)calloc(1, sizeof(*mutex));
+ if ( mutex ) {
+ pthread_mutexattr_init(&attr);
+ #if defined(PTHREAD_MUTEX_RECURSIVE)
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+ #elif defined(PTHREAD_MUTEX_RECURSIVE_NP)
+ pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
+ #else
+ /* No extra attributes necessary */
+ #endif
+ if ( pthread_mutex_init(&mutex->id, &attr) != 0 ) {
+ CLog::Log(LOGERROR, "pthread_mutex_init() failed");
+ free(mutex);
+ mutex = NULL;
+ }
+ } else {
+ CLog::Log(LOGERROR, "OutOfMemory");
+ }
+ return(mutex);
+#endif
+}
+
+void SDL_DestroyMutex(SDL_mutex *mutex)
+{
+#if defined(_WIN32)
+ if ( mutex ) {
+ if ( mutex->id ) {
+ CloseHandle(mutex->id);
+ mutex->id = 0;
+ }
+ free(mutex);
+ }
+#else
+
+ if ( mutex ) {
+ pthread_mutex_destroy(&mutex->id);
+ free(mutex);
+ }
+#endif
+}
+
+/* Lock the mutex */
+int SDL_mutexP(SDL_mutex *mutex)
+{
+#if defined(_WIN32)
+ if ( mutex == NULL ) {
+ CLog::Log(LOGERROR, "Passed a NULL mutex");
+ return -1;
+ }
+ if ( WaitForSingleObject(mutex->id, INFINITE) == WAIT_FAILED ) {
+ CLog::Log(LOGERROR, "Couldn't wait on mutex");
+ return -1;
+ }
+ return(0);
+#else
+ int retval;
+ #if defined(FAKE_RECURSIVE_MUTEX)
+ pthread_t this_thread;
+ #endif
+
+ if ( mutex == NULL ) {
+ CLog::Log(LOGERROR, "Passed a NULL mutex");
+ return -1;
+ }
+
+ retval = 0;
+ #if defined(FAKE_RECURSIVE_MUTEX)
+ this_thread = pthread_self();
+ if (pthread_equal(mutex->owner, this_thread)) {
+ //if ( mutex->owner == this_thread ) {
+ ++mutex->recursive;
+ } else {
+ /* The order of operations is important.
+ We set the locking thread id after we obtain the lock
+ so unlocks from other threads will fail.
+ */
+ if ( pthread_mutex_lock(&mutex->id) == 0 ) {
+ mutex->owner = this_thread;
+ mutex->recursive = 0;
+ } else {
+ CLog::Log(LOGERROR, "pthread_mutex_lock() failed");
+ retval = -1;
+ }
+ }
+ #else
+ if ( pthread_mutex_lock(&mutex->id) < 0 ) {
+ CLog::Log(LOGERROR, "pthread_mutex_lock() failed");
+ retval = -1;
+ }
+ #endif
+ return retval;
+#endif
+}
+
+int SDL_mutexV(SDL_mutex *mutex)
+{
+#if defined(_WIN32)
+ if ( mutex == NULL ) {
+ CLog::Log(LOGERROR, "Passed a NULL mutex");
+ return -1;
+ }
+ if ( ReleaseMutex(mutex->id) == FALSE ) {
+ CLog::Log(LOGERROR, "Couldn't release mutex");
+ return -1;
+ }
+ return(0);
+#else
+ int retval;
+
+ if ( mutex == NULL ) {
+ CLog::Log(LOGERROR, "Passed a NULL mutex");
+ return -1;
+ }
+
+ retval = 0;
+ #if defined(FAKE_RECURSIVE_MUTEX)
+ /* We can only unlock the mutex if we own it */
+ if (pthread_equal(pthread_self(), mutex->owner)) {
+ //if ( pthread_self() == mutex->owner ) {
+ if ( mutex->recursive ) {
+ --mutex->recursive;
+ } else {
+ /* The order of operations is important.
+ First reset the owner so another thread doesn't lock
+ the mutex and set the ownership before we reset it,
+ then release the lock semaphore.
+ */
+ mutex->owner = 0;
+ pthread_mutex_unlock(&mutex->id);
+ }
+ } else {
+ CLog::Log(LOGERROR, "mutex not owned by this thread");
+ retval = -1;
+ }
+
+ #else
+ if ( pthread_mutex_unlock(&mutex->id) < 0 ) {
+ CLog::Log(LOGERROR, "pthread_mutex_unlock() failed");
+ retval = -1;
+ }
+ #endif /* FAKE_RECURSIVE_MUTEX */
+
+ return retval;
+#endif
+}
+#endif \ No newline at end of file
diff --git a/xbmc/threads/XBMC_mutex.h b/xbmc/threads/XBMC_mutex.h
new file mode 100644
index 0000000000..100830ebe4
--- /dev/null
+++ b/xbmc/threads/XBMC_mutex.h
@@ -0,0 +1,85 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+
+#if defined(__APPLE__) && defined(__arm__)
+#ifndef _SDL_mutex_h
+#define _SDL_mutex_h
+
+#include <pthread.h>
+
+/* Functions to provide thread synchronization primitives
+
+ These are independent of the other SDL routines.
+*/
+
+/* Synchronization functions which can time out return this value
+ if they time out.
+*/
+#define SDL_MUTEX_TIMEDOUT 1
+
+/* This is the timeout value which corresponds to never time out */
+#define SDL_MUTEX_MAXWAIT (~(Uint32)0)
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* Mutex functions */
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* The SDL mutex structure, defined in SDL_mutex.c */
+#if !defined(_WIN32)
+ #if !PTHREAD_MUTEX_RECURSIVE && \
+ !PTHREAD_MUTEX_RECURSIVE_NP
+ #define FAKE_RECURSIVE_MUTEX
+ #endif
+#endif
+
+typedef struct SDL_mutex {
+#if defined(_WIN32)
+ HANDLE id;
+#else
+ pthread_mutex_t id;
+ #if defined(FAKE_RECURSIVE_MUTEX)
+ int recursive;
+ pthread_t owner;
+ #endif
+#endif
+} SDL_mutex;
+
+/* Create a mutex, initialized unlocked */
+SDL_mutex *SDL_CreateMutex(void);
+
+/* Lock the mutex (Returns 0, or -1 on error) */
+#define SDL_LockMutex(m) SDL_mutexP(m)
+int SDL_mutexP(SDL_mutex *mutex);
+
+/* Unlock the mutex (Returns 0, or -1 on error)
+ It is an error to unlock a mutex that has not been locked by
+ the current thread, and doing so results in undefined behavior.
+ */
+#define SDL_UnlockMutex(m) SDL_mutexV(m)
+int SDL_mutexV(SDL_mutex *mutex);
+
+/* Destroy a mutex */
+void SDL_DestroyMutex(SDL_mutex *mutex);
+
+#endif /* _SDL_mutex_h */
+#endif
diff --git a/xbmc/utils/PerformanceSample.cpp b/xbmc/utils/PerformanceSample.cpp
index f6a9dde580..b7a0f9d615 100644
--- a/xbmc/utils/PerformanceSample.cpp
+++ b/xbmc/utils/PerformanceSample.cpp
@@ -26,7 +26,6 @@
#include "linux/PlatformInclude.h"
#endif
-#include <SDL/SDL.h>
#include "Application.h"
#include "log.h"
#include "TimeUtils.h"
diff --git a/xbmc/video/Teletext.cpp b/xbmc/video/Teletext.cpp
index 9d606921a0..f7b989fb96 100644
--- a/xbmc/video/Teletext.cpp
+++ b/xbmc/video/Teletext.cpp
@@ -32,6 +32,13 @@
#include "utils/TimeUtils.h"
#include "filesystem/SpecialProtocol.h"
+#ifndef HAS_SDL
+#define SDL_memset4(dst, val, len) memset(dst, val, (len)*4)
+#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len)*4)
+#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len)*4)
+#define SDL_memset4(dst, val, len) memset(dst, val, (len)*4)
+#endif
+
using namespace std;
static const char *TeletextFont = "special://xbmc/media/Fonts/teletext.ttf";
diff --git a/xbmc/windowing/WinEvents.h b/xbmc/windowing/WinEvents.h
index e55dc8de93..d7c2fe972e 100644
--- a/xbmc/windowing/WinEvents.h
+++ b/xbmc/windowing/WinEvents.h
@@ -41,9 +41,14 @@ public:
#endif
#ifdef _LINUX
+#if defined(__APPLE__) && defined(__arm__)
+#include "osx/WinEventsIOS.h"
+#define CWinEvents CWinEventsIOS
+#else
#include "WinEventsSDL.h"
#define CWinEvents CWinEventsSDL
#endif
+#endif
#endif // WINDOW_EVENTS_H
diff --git a/xbmc/windowing/WinEventsSDL.h b/xbmc/windowing/WinEventsSDL.h
index 7d8795ae0e..2112568655 100644
--- a/xbmc/windowing/WinEventsSDL.h
+++ b/xbmc/windowing/WinEventsSDL.h
@@ -18,14 +18,14 @@
* http://www.gnu.org/copyleft/gpl.html
*
*/
+#pragma once
#ifndef WINDOW_EVENTS_SDL_H
#define WINDOW_EVENTS_SDL_H
+#ifdef HAS_SDL
#include <SDL/SDL_events.h>
-#pragma once
-
#include "WinEvents.h"
class CWinEventsSDL : public CWinEventsBase
@@ -41,4 +41,5 @@ protected:
#endif
};
+#endif
#endif // WINDOW_EVENTS_SDL_H
diff --git a/xbmc/windowing/osx/WinEventsIOS.h b/xbmc/windowing/osx/WinEventsIOS.h
new file mode 100644
index 0000000000..e0b4f78f01
--- /dev/null
+++ b/xbmc/windowing/osx/WinEventsIOS.h
@@ -0,0 +1,40 @@
+/*
+* Copyright (C) 2010 Team XBMC
+* http://www.xbmc.org
+*
+* This Program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2, or (at your option)
+* any later version.
+*
+* This Program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with XBMC; see the file COPYING. If not, write to
+* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+* http://www.gnu.org/copyleft/gpl.html
+*
+*/
+
+#pragma once
+
+#ifndef WINDOW_EVENTS_IOS_H
+#define WINDOW_EVENTS_IOS_H
+
+#include "WinEvents.h"
+
+class CWinEventsIOS : public CWinEventsBase
+{
+public:
+ static void Init();
+ static void DeInit();
+ static void MessagePush(XBMC_Event *newEvent);
+ static bool MessagePump();
+
+protected:
+};
+
+#endif // WINDOW_EVENTS_IOS_H
diff --git a/xbmc/windowing/osx/WinEventsIOS.mm b/xbmc/windowing/osx/WinEventsIOS.mm
new file mode 100644
index 0000000000..bc6f7eaad6
--- /dev/null
+++ b/xbmc/windowing/osx/WinEventsIOS.mm
@@ -0,0 +1,91 @@
+/*
+* Copyright (C) 2010 Team XBMC
+* http://www.xbmc.org
+*
+* This Program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2, or (at your option)
+* any later version.
+*
+* This Program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with XBMC; see the file COPYING. If not, write to
+* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+* http://www.gnu.org/copyleft/gpl.html
+*
+*/
+
+#include "system.h"
+#include "WinEvents.h"
+#include "WinEventsIOS.h"
+#include "XBMC_vkeys.h"
+#include "Application.h"
+#include "WindowingFactory.h"
+#include "XBMC_mutex.h"
+
+static SDL_mutex *m_inputMutex = NULL;
+
+PHANDLE_EVENT_FUNC CWinEventsBase::m_pEventFunc = NULL;
+
+static std::vector<XBMC_Event> events;
+
+void CWinEventsIOS::DeInit()
+{
+ if (m_inputMutex)
+ SDL_DestroyMutex(m_inputMutex);
+ m_inputMutex = NULL;
+}
+
+void CWinEventsIOS::Init()
+{
+ m_inputMutex = SDL_CreateMutex();
+}
+
+void CWinEventsIOS::MessagePush(XBMC_Event *newEvent)
+{
+ SDL_mutexP(m_inputMutex);
+
+ events.push_back(*newEvent);
+
+ SDL_mutexV(m_inputMutex);
+}
+
+bool CWinEventsIOS::MessagePump()
+{
+ bool ret = false;
+ bool gotEvent = false;
+ XBMC_Event pumpEvent;
+
+ SDL_mutexP(m_inputMutex);
+ for (vector<XBMC_Event>::iterator it = events.begin(); it!=events.end(); ++it)
+ {
+ memcpy(&pumpEvent, (XBMC_Event *)&*it, sizeof(XBMC_Event));
+ events.erase (events.begin(),events.begin()+1);
+ gotEvent = true;
+ break;
+ }
+ SDL_mutexV(m_inputMutex);
+
+ if (gotEvent)
+ {
+ if (pumpEvent.type == XBMC_USEREVENT)
+ {
+ // On ATV2, we push in events as a XBMC_USEREVENT,
+ // the user.code will be the keyID to translate using JoyStick.AppleRemote.xml
+ std::string joystickName = "AppleRemote";
+ bool isAxis = false;
+ float fAmount = 0.0;
+ unsigned short wKeyID = pumpEvent.user.code;
+
+ ret |= g_application.ProcessJoystickEvent(joystickName, wKeyID, isAxis, fAmount);
+ }
+ else
+ ret |= g_application.OnEvent(pumpEvent);
+ }
+
+ return ret;
+}