diff options
author | Memphiz <memphis@machzwo.de> | 2011-07-01 23:47:57 +0200 |
---|---|---|
committer | Memphiz <memphis@machzwo.de> | 2011-07-01 23:47:57 +0200 |
commit | 119f1bd7c710d2487cf069d9c033c1df7cd420fa (patch) | |
tree | 4940cb69713de4eabeb307ab5d0e4541371f8e2e | |
parent | 2aea49b8e0aa4db649818353d0f1756854b0a487 (diff) |
[refactored] - moved IsAppleTV2 to DarwinUtils
- make IsAppleTV2 cache the result
-rw-r--r-- | xbmc/osx/DarwinUtils.h | 1 | ||||
-rw-r--r-- | xbmc/osx/DarwinUtils.mm | 22 | ||||
-rw-r--r-- | xbmc/utils/SystemInfo.cpp | 14 | ||||
-rw-r--r-- | xbmc/windowing/osx/WinSystemIOS.mm | 4 |
4 files changed, 26 insertions, 15 deletions
diff --git a/xbmc/osx/DarwinUtils.h b/xbmc/osx/DarwinUtils.h index daab73da22..9278b6575c 100644 --- a/xbmc/osx/DarwinUtils.h +++ b/xbmc/osx/DarwinUtils.h @@ -27,6 +27,7 @@ extern "C" { #endif + bool DarwinIsAppleTV2(void); float GetIOSVersion(void); int GetDarwinFrameworkPath(bool forPython, char* path, uint32_t *pathsize); int GetDarwinExecutablePath(char* path, uint32_t *pathsize); diff --git a/xbmc/osx/DarwinUtils.mm b/xbmc/osx/DarwinUtils.mm index cacca43ba3..6a0388be00 100644 --- a/xbmc/osx/DarwinUtils.mm +++ b/xbmc/osx/DarwinUtils.mm @@ -38,6 +38,28 @@ #import "AutoPool.h" #import "DarwinUtils.h" + +bool DarwinIsAppleTV2(void) +{ + static int result = -1; +#if defined(__APPLE__) && defined(__arm__) + if( result == -1 ) + { + char buffer[512]; + size_t len = 512; + result = false; + std::string hw_machine = "unknown"; + + if (sysctlbyname("hw.machine", &buffer, &len, NULL, 0) == 0) + hw_machine = buffer; + + if (hw_machine.find("AppleTV2,1") != std::string::npos) + result = true; + } +#endif + return result; +} + float GetIOSVersion(void) { CCocoaAutoPool pool; diff --git a/xbmc/utils/SystemInfo.cpp b/xbmc/utils/SystemInfo.cpp index 8fb83a6a18..f692f7a8ad 100644 --- a/xbmc/utils/SystemInfo.cpp +++ b/xbmc/utils/SystemInfo.cpp @@ -711,19 +711,7 @@ bool CSysInfo::IsAppleTV() bool CSysInfo::IsAppleTV2() { - bool result = false; -#if defined(__APPLE__) && defined(__arm__) - char buffer[512]; - size_t len = 512; - std::string hw_machine = "unknown"; - - if (sysctlbyname("hw.machine", &buffer, &len, NULL, 0) == 0) - hw_machine = buffer; - - if (hw_machine.find("AppleTV2,1") != std::string::npos) - result = true; -#endif - return result; + return DarwinIsAppleTV2(); } bool CSysInfo::HasVideoToolBoxDecoder() diff --git a/xbmc/windowing/osx/WinSystemIOS.mm b/xbmc/windowing/osx/WinSystemIOS.mm index 6e0418f75e..f36501b3ee 100644 --- a/xbmc/windowing/osx/WinSystemIOS.mm +++ b/xbmc/windowing/osx/WinSystemIOS.mm @@ -40,7 +40,7 @@ #import <OpenGLES/ES2/gl.h> #import <OpenGLES/ES2/glext.h> #import "XBMCController.h" -#include "utils/SystemInfo.h" +#include "osx/DarwinUtils.h" #import <dlfcn.h> CWinSystemIOS::CWinSystemIOS() : CWinSystemBase() @@ -203,7 +203,7 @@ void CWinSystemIOS::ShowOSMouse(bool show) bool CWinSystemIOS::HasCursor() { - if( g_sysinfo.IsAppleTV2() ) + if( DarwinIsAppleTV2() ) { return true; } |