lib/xbmc-dll-symbols/dll-symbols.a \
xbmc/addons/addons.a \
xbmc/cdrip/cdrip.a \
+ xbmc/commons/commons.a \
xbmc/cores/AudioRenderers/audiorenderers.a \
xbmc/cores/DllLoader/dllloader.a \
xbmc/cores/DllLoader/exports/exports.a \
lib/libXDAAP/libxdaap.a \
lib/SlingboxLib/SlingboxLib.a
-
OBJSXBMC =$(DIRECTORY_ARCHIVES)
OBJSXBMC+=lib/libapetag/.libs/libapetag.a
LIBS += @PYTHON_LDFLAGS@
-xbmc.bin: $(OBJSXBMC) $(DYNOBJSXBMC)
+xbmc.bin: $(OBJSXBMC) $(DYNOBJSXBMC) $(NWAOBJSXBMC)
+
ifeq ($(findstring osx,@ARCH@), osx)
$(SILENT_LD) $(CXX) $(LDFLAGS) -o xbmc.bin -Wl,-all_load,-ObjC $(DYNOBJSXBMC) $(OBJSXBMC) $(LIBS) -rdynamic
else
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug (DirectX)|Win32">
<ClCompile Include="..\..\xbmc\Autorun.cpp" />
<ClCompile Include="..\..\xbmc\AutoSwitch.cpp" />
<ClCompile Include="..\..\xbmc\BackgroundInfoLoader.cpp" />
+ <ClCompile Include="..\..\xbmc\commons\ilog.cpp" />
<ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Video\CrystalHD.cpp" />
<ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDInputStreams\DVDInputStreamBluray.cpp" />
<ClCompile Include="..\..\xbmc\cores\paplayer\BXAcodec.cpp" />
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (OpenGL)|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Template|Win32'">true</ExcludedFromBuild>
</ClCompile>
+ <ClCompile Include="..\..\xbmc\XbmcContext.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\lib\DllAvFilter.h" />
<ClInclude Include="..\..\xbmc\Autorun.h" />
<ClInclude Include="..\..\xbmc\AutoSwitch.h" />
<ClInclude Include="..\..\xbmc\BackgroundInfoLoader.h" />
+ <ClInclude Include="..\..\xbmc\commons\ilog.h" />
<ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Video\CrystalHD.h" />
<ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDInputStreams\DVDInputStreamBluray.h" />
<ClInclude Include="..\..\xbmc\cores\paplayer\BXAcodec.h" />
<ClInclude Include="..\..\xbmc\win32\pch.h" />
<ClInclude Include="..\..\xbmc\win32\PlatformDefs.h" />
<ClInclude Include="..\..\xbmc\XBDateTime.h" />
+ <ClInclude Include="..\..\xbmc\XbmcContext.h" />
<CustomBuild Include="..\..\xbmc\win32\PlatformInclude.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">update_git_rev.bat</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">..\..\xbmc\win32\git_rev.h;%(Outputs)</Outputs>
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="win32">
<Filter Include="network\httprequesthandler">
<UniqueIdentifier>{9029e610-aa5a-4414-9e96-1d69f03b3bd8}</UniqueIdentifier>
</Filter>
+ <Filter Include="commons">
+ <UniqueIdentifier>{d72cae28-bfc8-4a16-befc-dab99a62407b}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\xbmc\win32\pch.cpp">
<ClCompile Include="..\..\xbmc\MediaSource.cpp">
<Filter>utils</Filter>
</ClCompile>
+ <ClCompile Include="..\..\xbmc\XbmcContext.cpp" />
+ <ClCompile Include="..\..\xbmc\commons\ilog.cpp">
+ <Filter>commons</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\xbmc\win32\pch.h">
<ClInclude Include="..\..\xbmc\win32\WindowHelper.h">
<Filter>win32</Filter>
</ClInclude>
+ <ClInclude Include="..\..\xbmc\win32\WINFileSMB.h">
+ <Filter>win32</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\xbmc\win32\WINSMBDirectory.h">
+ <Filter>win32</Filter>
+ </ClInclude>
<ClInclude Include="..\..\xbmc\cores\DummyVideoPlayer.h">
<Filter>cores</Filter>
</ClInclude>
<Filter>filesystem</Filter>
</ClInclude>
<ClInclude Include="..\..\xbmc\cores\paplayer\PCMCodec.h">
- <Filter>cores\paplayer</Filter>
+ <Filter>cores\paplayer</Filter>=
+ </ClInclude>
+ <ClInclude Include="..\..\xbmc\XbmcContext.h" />
+ <ClInclude Include="..\..\xbmc\commons\ilog.h">
+ <Filter>commons</Filter>
</ClInclude>
<ClInclude Include="..\..\xbmc\filesystem\MemBufferCache.h">
<Filter>filesystem</Filter>
XBApplicationEx.cpp \
XBDateTime.cpp \
xbmc.cpp \
+ XbmcContext.cpp \
LIB=xbmc.a
--- /dev/null
+/*
+ * Copyright (C) 2005-2011 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 "XbmcContext.h"
+
+#include "threads/Thread.h"
+#include "utils/log.h"
+
+namespace XBMC
+{
+
+ class ContextOpaque
+ {
+ public:
+ XbmcCommons::ILogger* loggerImpl;
+
+ ContextOpaque() : loggerImpl(NULL) {}
+ };
+
+ Context::Context()
+ {
+ impl = new ContextOpaque;
+
+ // instantiate
+ impl->loggerImpl = new XbmcUtils::LogImplementation;
+
+ // set
+ CThread::SetLogger(impl->loggerImpl);
+ }
+
+ Context::~Context()
+ {
+ // cleanup
+ delete impl->loggerImpl;
+
+ delete impl;
+ }
+}
+
--- /dev/null
+/*
+ * Copyright (C) 2005-2011 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
+
+namespace XBMC
+{
+ class ContextOpaque;
+
+ /**
+ * This class sets up a few instances and services. Currently it only
+ * provides a logger to the CThread functionality. If it never does
+ * more than this it can be removed.
+ */
+ class Context
+ {
+ ContextOpaque* impl;
+ public:
+ Context();
+ virtual ~Context();
+ };
+}
+
+
+
--- /dev/null
+SRCS= \
+ ilog.cpp
+
+
+LIB=commons.a
+
+include ../../Makefile.include
+-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(patsubst %.S,,$(SRCS))))
--- /dev/null
+/*
+ * Copyright (C) 2005-2011 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 "commons/ilog.h"
+#include "utils/StdString.h"
+
+namespace XbmcCommons
+{
+ void ILogger::Log(int loglevel, const char *format, ... )
+ {
+ CStdString strData;
+
+ strData.reserve(16384);
+ va_list va;
+ va_start(va, format);
+ strData.FormatV(format,va);
+ va_end(va);
+
+ log(loglevel, strData);
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2005-2011 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
+
+#include <stdio.h>
+
+#define LOG_LEVEL_NONE -1 // nothing at all is logged
+#define LOG_LEVEL_NORMAL 0 // shows notice, error, severe and fatal
+#define LOG_LEVEL_DEBUG 1 // shows all
+#define LOG_LEVEL_DEBUG_FREEMEM 2 // shows all + shows freemem on screen
+#define LOG_LEVEL_DEBUG_SAMBA 3 // shows all + freemem on screen + samba debugging
+#define LOG_LEVEL_MAX LOG_LEVEL_DEBUG_SAMBA
+
+// ones we use in the code
+#define LOGDEBUG 0
+#define LOGINFO 1
+#define LOGNOTICE 2
+#define LOGWARNING 3
+#define LOGERROR 4
+#define LOGSEVERE 5
+#define LOGFATAL 6
+#define LOGNONE 7
+
+#ifdef __GNUC__
+#define ATTRIB_LOG_FORMAT __attribute__((format(printf,3,4)))
+#else
+#define ATTRIB_LOG_FORMAT
+#endif
+
+namespace XbmcCommons
+{
+ class ILogger
+ {
+ public:
+ void Log(int loglevel, const char *format, ... ) ATTRIB_LOG_FORMAT;
+
+ virtual void log(int loglevel, const char* message) = 0;
+ };
+}
+
+#undef ATTRIB_LOG_FORMAT
#include "threads/SystemClock.h"
#include "Thread.h"
#include "utils/log.h"
-#include "utils/TimeUtils.h"
#include "threads/ThreadLocal.h"
+#include "threads/SingleLock.h"
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
static XbmcThreads::ThreadLocal<CThread> currentThread;
+XbmcCommons::ILogger* CThread::logger = NULL;
+
#include "threads/platform/ThreadImpl.cpp"
//////////////////////////////////////////////////////////////////////
bool autodelete;
if (!pThread) {
- CLog::Log(LOGERROR,"%s, sanity failed. thread is NULL.",__FUNCTION__);
+ if(logger) logger->Log(LOGERROR,"%s, sanity failed. thread is NULL.",__FUNCTION__);
return 1;
}
pThread->SetThreadInfo();
- CLog::Log(LOGNOTICE,"Thread %s start, auto delete: %s", name.c_str(), (autodelete ? "true" : "false"));
+ if(logger) logger->Log(LOGNOTICE,"Thread %s start, auto delete: %s", name.c_str(), (autodelete ? "true" : "false"));
currentThread.set(pThread);
pThread->m_StartEvent.Set();
if (autodelete)
{
- CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating (autodelete)", name.c_str(), (uint64_t)id);
+ if(logger) logger->Log(LOGDEBUG,"Thread %s %"PRIu64" terminating (autodelete)", name.c_str(), (uint64_t)id);
delete pThread;
pThread = NULL;
}
else
- CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating", name.c_str(), (uint64_t)id);
+ if(logger) logger->Log(LOGDEBUG,"Thread %s %"PRIu64" terminating", name.c_str(), (uint64_t)id);
return 0;
}
#include "Event.h"
#include "threads/ThreadImpl.h"
#include "threads/ThreadLocal.h"
+#include "commons/ilog.h"
class IRunnable
{
// minimum as mandated by XTL
#define THREAD_MINSTACKSIZE 0x10000
+namespace XbmcThreads { class ThreadSettings; }
+
class CThread
{
-public:
+ static XbmcCommons::ILogger* logger;
+
+protected:
CThread(const char* ThreadName);
+
+public:
CThread(IRunnable* pRunnable, const char* ThreadName);
virtual ~CThread();
void Create(bool bAutoDelete = false, unsigned stacksize = 0);
static ThreadIdentifier GetCurrentThreadId();
static CThread* GetCurrentThread();
static int64_t GetCurrentThreadUsage();
+ static inline void SetLogger(XbmcCommons::ILogger* logger_) { CThread::logger = logger_; }
protected:
virtual void OnStartup(){};
virtual void OnExit(){};
{
XbmcThreads::CEventGroup group(&event, &m_StopEvent, NULL);
CEvent* result = group.wait(timeoutMillis);
- return result == &event ? WAIT_SIGNALED :
+ return result == &event ? WAIT_SIGNALED :
(result == NULL ? WAIT_TIMEDOUT : WAIT_INTERRUPTED);
}
{
XbmcThreads::CEventGroup group(&event, &m_StopEvent, NULL);
CEvent* result = group.wait();
- return result == &event ? WAIT_SIGNALED :
+ return result == &event ? WAIT_SIGNALED :
(result == NULL ? WAIT_TIMEDOUT : WAIT_INTERRUPTED);
}
{
if (m_ThreadId != 0)
{
- CLog::Log(LOGERROR, "%s - fatal error creating thread- old thread id not null", __FUNCTION__);
+ if (logger) logger->Log(LOGERROR, "%s - fatal error creating thread- old thread id not null", __FUNCTION__);
exit(1);
}
m_iLastTime = XbmcThreads::SystemClockMillis() * 10000;
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (pthread_create(&m_ThreadId, &attr, (void*(*)(void*))staticThread, this) != 0)
{
- CLog::Log(LOGNOTICE, "%s - fatal error creating thread",__FUNCTION__);
+ if (logger) logger->Log(LOGNOTICE, "%s - fatal error creating thread",__FUNCTION__);
}
pthread_attr_destroy(&attr);
}
// start thread with nice level of appication
int appNice = getpriority(PRIO_PROCESS, getpid());
if (setpriority(PRIO_PROCESS, m_ThreadOpaque.LwpId, appNice) != 0)
- CLog::Log(LOGERROR, "%s: error %s", __FUNCTION__, strerror(errno));
+ if (logger) logger->Log(LOGERROR, "%s: error %s", __FUNCTION__, strerror(errno));
}
ThreadIdentifier CThread::GetCurrentThreadId()
if (setpriority(PRIO_PROCESS, m_ThreadOpaque.LwpId, prio) == 0)
bReturn = true;
else
- CLog::Log(LOGERROR, "%s: error %s", __FUNCTION__, strerror(errno));
+ if (logger) logger->Log(LOGERROR, "%s: error %s", __FUNCTION__, strerror(errno));
}
return bReturn;
{
if (m_ThreadId != 0)
{
- CLog::Log(LOGERROR, "%s - fatal error creating thread- old thread id not null", __FUNCTION__);
+ if (logger) logger->Log(LOGERROR, "%s - fatal error creating thread- old thread id not null", __FUNCTION__);
exit(1);
}
m_iLastTime = XbmcThreads::SystemClockMillis() * 10000;
m_ThreadOpaque.handle = CreateThread(NULL,stacksize, (LPTHREAD_START_ROUTINE)&staticThread, this, 0, &m_ThreadId);
if (m_ThreadOpaque.handle == NULL)
{
- CLog::Log(LOGERROR, "%s - fatal error creating thread", __FUNCTION__);
+ if (logger) logger->Log(LOGERROR, "%s - fatal error creating thread", __FUNCTION__);
}
}
#include <stdio.h>
#include <string>
+#include "commons/ilog.h"
#include "threads/CriticalSection.h"
#include "utils/GlobalsHandling.h"
-#define LOG_LEVEL_NONE -1 // nothing at all is logged
-#define LOG_LEVEL_NORMAL 0 // shows notice, error, severe and fatal
-#define LOG_LEVEL_DEBUG 1 // shows all
-#define LOG_LEVEL_DEBUG_FREEMEM 2 // shows all + shows freemem on screen
-#define LOG_LEVEL_DEBUG_SAMBA 3 // shows all + freemem on screen + samba debugging
-#define LOG_LEVEL_MAX LOG_LEVEL_DEBUG_SAMBA
-
-// ones we use in the code
-#define LOGDEBUG 0
-#define LOGINFO 1
-#define LOGNOTICE 2
-#define LOGWARNING 3
-#define LOGERROR 4
-#define LOGSEVERE 5
-#define LOGFATAL 6
-#define LOGNONE 7
-
#ifdef __GNUC__
#define ATTRIB_LOG_FORMAT __attribute__((format(printf,2,3)))
#else
static void OutputDebugString(const std::string& line);
};
+#undef ATTRIB_LOG_FORMAT
+
+namespace XbmcUtils
+{
+ class LogImplementation : public XbmcCommons::ILogger
+ {
+ public:
+ inline virtual void log(int logLevel, const char* message) { CLog::Log(logLevel,"%s",message); }
+ };
+}
+
XBMC_GLOBAL_REF(CLog::CLogGlobals,g_log_globals);
#ifdef HAS_LIRC
#include "input/linux/LIRC.h"
#endif
+#include "XbmcContext.h"
int main(int argc, char* argv[])
{
+ // set up some xbmc specific relationships
+ XBMC::Context context;
+
int status = -1;
//this can't be set from CAdvancedSettings::Initialize() because it will overwrite
//the loglevel set with the --debug flag