Created
July 12, 2015 20:38
-
-
Save Fma965/b01099fd866c133cb257 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 53fe87d9f3af7325418f37ae2e673732a013b0c6 Mon Sep 17 00:00:00 2001 | |
From: root <root@CY-HEADLESS.(none)> | |
Date: Sun, 12 Jul 2015 21:35:51 +0100 | |
Subject: [PATCH 1/1] headless | |
--- | |
xbmc/AppParamParser.cpp | 2 ++ | |
xbmc/Application.cpp | 52 +++++++++++++++++++---------------- | |
xbmc/Application.h | 19 ++++++++++--- | |
xbmc/guilib/GUIDialog.cpp | 4 +-- | |
xbmc/guilib/GUIWindow.cpp | 10 +++---- | |
xbmc/settings/SettingConditions.cpp | 3 ++ | |
xbmc/xbmc.cpp | 2 +- | |
7 files changed, 56 insertions(+), 36 deletions(-) | |
diff --git a/xbmc/AppParamParser.cpp b/xbmc/AppParamParser.cpp | |
index 08f4dad..11f3655 100644 | |
--- a/xbmc/AppParamParser.cpp | |
+++ b/xbmc/AppParamParser.cpp | |
@@ -137,6 +137,8 @@ void CAppParamParser::ParseArg(const std::string &arg) | |
m_testmode = true; | |
else if (arg.substr(0, 11) == "--settings=") | |
g_advancedSettings.AddSettingsFile(arg.substr(11)); | |
+ else if (arg == "--headless") | |
+ g_application.SetHeadless(true); | |
else if (arg.length() != 0 && arg[0] != '-') | |
{ | |
if (m_testmode) | |
diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp | |
index 697f278..f3b8b9f 100644 | |
--- a/xbmc/Application.cpp | |
+++ b/xbmc/Application.cpp | |
@@ -292,6 +292,7 @@ CApplication::CApplication(void) | |
m_bPlatformDirectories = true; | |
m_bStandalone = false; | |
+ m_headless = false; | |
m_bEnableLegacyRes = false; | |
m_bSystemScreenSaverEnable = false; | |
m_pInertialScrollingHandler = new CInertialScrollingHandler(); | |
@@ -540,7 +541,7 @@ bool CApplication::Create() | |
CLog::Log(LOGNOTICE, "WARNING: unsupported ffmpeg version detected"); | |
} | |
#endif | |
- | |
+ | |
std::string cpuModel(g_cpuInfo.getCPUModel()); | |
if (!cpuModel.empty()) | |
CLog::Log(LOGNOTICE, "Host CPU: %s, %d core%s available", cpuModel.c_str(), g_cpuInfo.getCPUCount(), (g_cpuInfo.getCPUCount() == 1) ? "" : "s"); | |
@@ -1499,7 +1500,7 @@ bool CApplication::OnSettingUpdate(CSetting* &setting, const char *oldSettingId, | |
CSettingString *audioDevice = (CSettingString*)setting; | |
// Gotham and older didn't enumerate audio devices per stream on osx | |
// add stream0 per default which should be ok for all old settings. | |
- if (!StringUtils::EqualsNoCase(audioDevice->GetValue(), "DARWINOSX:default") && | |
+ if (!StringUtils::EqualsNoCase(audioDevice->GetValue(), "DARWINOSX:default") && | |
StringUtils::FindWords(audioDevice->GetValue().c_str(), ":stream") == std::string::npos) | |
{ | |
std::string newSetting = audioDevice->GetValue(); | |
@@ -2112,8 +2113,8 @@ bool CApplication::OnAction(const CAction &action) | |
if (action.IsMouse()) | |
CInputManager::Get().SetMouseActive(true); | |
- | |
- if (action.GetID() == ACTION_CREATE_EPISODE_BOOKMARK) | |
+ | |
+ if (action.GetID() == ACTION_CREATE_EPISODE_BOOKMARK) | |
{ | |
CGUIDialogVideoBookmarks::OnAddEpisodeBookmark(); | |
} | |
@@ -2121,7 +2122,7 @@ bool CApplication::OnAction(const CAction &action) | |
{ | |
CGUIDialogVideoBookmarks::OnAddBookmark(); | |
} | |
- | |
+ | |
// The action PLAYPAUSE behaves as ACTION_PAUSE if we are currently | |
// playing or ACTION_PLAYER_PLAY if we are seeking (FF/RW) or not playing. | |
if (action.GetID() == ACTION_PLAYER_PLAYPAUSE) | |
@@ -2150,7 +2151,7 @@ bool CApplication::OnAction(const CAction &action) | |
// notify action listeners | |
if (NotifyActionListeners(action)) | |
return true; | |
- | |
+ | |
// screenshot : take a screenshot :) | |
if (action.GetID() == ACTION_TAKE_SCREENSHOT) | |
{ | |
@@ -2571,7 +2572,7 @@ bool CApplication::Cleanup() | |
#ifdef HAS_DVD_DRIVE | |
CLibcdio::ReleaseInstance(); | |
#endif | |
-#endif | |
+#endif | |
#if defined(TARGET_ANDROID) | |
// enable for all platforms once it's safe | |
g_sectionLoader.UnloadAll(); | |
@@ -2857,7 +2858,7 @@ PlayBackRet CApplication::PlayStack(const CFileItem& item, bool bRestart) | |
else | |
{ | |
LoadVideoSettings(item); | |
- | |
+ | |
// see if we have the info in the database | |
// TODO: If user changes the time speed (FPS via framerate conversion stuff) | |
// then these times will be wrong. | |
@@ -3155,7 +3156,7 @@ PlayBackRet CApplication::PlayFile(const CFileItem& item, bool bRestart) | |
CSingleLock lock(m_playStateMutex); | |
// tell system we are starting a file | |
m_bPlaybackStarting = true; | |
- | |
+ | |
// for playing a new item, previous playing item's callback may already | |
// pushed some delay message into the threadmessage list, they are not | |
// expected be processed after or during the new item playback starting. | |
@@ -3476,7 +3477,7 @@ void CApplication::SaveFileState(bool bForeground /* = false */) | |
m_progressTrackingVideoResumeBookmark, | |
m_progressTrackingPlayCountUpdate, | |
CMediaSettings::Get().GetCurrentVideoSettings()); | |
- | |
+ | |
if (bForeground) | |
{ | |
// Run job in the foreground to make sure it finishes | |
@@ -3573,11 +3574,11 @@ void CApplication::LoadVideoSettings(const CFileItem& item) | |
if (dbs.Open()) | |
{ | |
CLog::Log(LOGDEBUG, "Loading settings for %s", item.GetPath().c_str()); | |
- | |
+ | |
// Load stored settings if they exist, otherwise use default | |
if (!dbs.GetVideoSettings(item, CMediaSettings::Get().GetCurrentVideoSettings())) | |
CMediaSettings::Get().GetCurrentVideoSettings() = CMediaSettings::Get().GetDefaultVideoSettings(); | |
- | |
+ | |
dbs.Close(); | |
} | |
} | |
@@ -3917,7 +3918,7 @@ bool CApplication::OnMessage(CGUIMessage& message) | |
// Update our infoManager with the new details etc. | |
if (m_nextPlaylistItem >= 0) | |
- { | |
+ { | |
// playing an item which is not in the list - player might be stopped already | |
// so do nothing | |
if (playList.size() <= m_nextPlaylistItem) | |
@@ -4076,15 +4077,18 @@ bool CApplication::OnMessage(CGUIMessage& message) | |
if (!m_pPlayer->IsPlayingVideo()) | |
{ | |
- if(g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO) | |
+ if (!IsHeadless()) | |
{ | |
- g_windowManager.PreviousWindow(); | |
- } | |
- else | |
- { | |
- CSingleLock lock(g_graphicsContext); | |
- // resets to res_desktop or look&feel resolution (including refreshrate) | |
- g_graphicsContext.SetFullScreenVideo(false); | |
+ if(g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO) | |
+ { | |
+ g_windowManager.PreviousWindow(); | |
+ } | |
+ else | |
+ { | |
+ CSingleLock lock(g_graphicsContext); | |
+ // resets to res_desktop or look&feel resolution (including refreshrate) | |
+ g_graphicsContext.SetFullScreenVideo(false); | |
+ } | |
} | |
} | |
@@ -4514,7 +4518,7 @@ float CApplication::GetVolume(bool percentage /* = true */) const | |
// converts the hardware volume to a percentage | |
return m_volumeLevel * 100.0f; | |
} | |
- | |
+ | |
return m_volumeLevel; | |
} | |
@@ -4959,7 +4963,7 @@ void CApplication::CloseNetworkShares() | |
#if defined(HAS_FILESYSTEM_SMB) && !defined(TARGET_WINDOWS) | |
smb.Deinit(); | |
#endif | |
- | |
+ | |
#ifdef HAS_FILESYSTEM_NFS | |
gNfsConnection.Deinit(); | |
#endif | |
@@ -4993,6 +4997,6 @@ bool CApplication::NotifyActionListeners(const CAction &action) const | |
if ((*it)->OnAction(action)) | |
return true; | |
} | |
- | |
+ | |
return false; | |
} | |
diff --git a/xbmc/Application.h b/xbmc/Application.h | |
index 4b50ab2..fa28207 100644 | |
--- a/xbmc/Application.h | |
+++ b/xbmc/Application.h | |
@@ -338,6 +338,16 @@ public: | |
return m_bStandalone; | |
} | |
+ void SetHeadless(bool value) | |
+ { | |
+ m_headless = value; | |
+ } | |
+ | |
+ bool IsHeadless() const | |
+ { | |
+ return m_headless; | |
+ } | |
+ | |
void SetEnableLegacyRes(bool value) | |
{ | |
m_bEnableLegacyRes = value; | |
@@ -377,7 +387,7 @@ public: | |
ReplayGainSettings& GetReplayGainSettings() { return m_replayGainSettings; } | |
void SetLoggingIn(bool loggingIn) { m_loggingIn = loggingIn; } | |
- | |
+ | |
/*! | |
\brief Register an action listener. | |
\param listener The listener to register | |
@@ -401,7 +411,7 @@ protected: | |
bool LoadSkin(const std::string& skinID); | |
bool LoadSkin(const std::shared_ptr<ADDON::CSkinInfo>& skin); | |
- | |
+ | |
/*! | |
\brief Delegates the action to all registered action handlers. | |
\param action The action | |
@@ -466,6 +476,7 @@ protected: | |
bool m_skipGuiRender; | |
bool m_bStandalone; | |
+ bool m_headless; | |
bool m_bEnableLegacyRes; | |
bool m_bTestMode; | |
bool m_bSystemScreenSaverEnable; | |
@@ -500,11 +511,11 @@ protected: | |
#endif | |
ReplayGainSettings m_replayGainSettings; | |
- | |
+ | |
std::vector<IActionListener *> m_actionListeners; | |
bool m_fallbackLanguageLoaded; | |
- | |
+ | |
private: | |
CCriticalSection m_critSection; /*!< critical section for all changes to this class, except for changes to triggers */ | |
}; | |
diff --git a/xbmc/guilib/GUIDialog.cpp b/xbmc/guilib/GUIDialog.cpp | |
index 18eacac..1168234 100644 | |
--- a/xbmc/guilib/GUIDialog.cpp | |
+++ b/xbmc/guilib/GUIDialog.cpp | |
@@ -165,7 +165,7 @@ void CGUIDialog::DoModal_Internal(int iWindowID /*= WINDOW_INVALID */, const std | |
//maybe we should have a critical section per window instead?? | |
CSingleLock lock(g_graphicsContext); | |
- if (!g_windowManager.Initialized()) | |
+ if (!g_windowManager.Initialized() || g_application.IsHeadless()) | |
return; // don't do anything | |
m_closing = false; | |
@@ -201,7 +201,7 @@ void CGUIDialog::Show_Internal() | |
if (m_active && !m_closing && !IsAnimating(ANIM_TYPE_WINDOW_CLOSE)) return; | |
- if (!g_windowManager.Initialized()) | |
+ if (g_application.IsHeadless()) | |
return; // don't do anything | |
m_modalityType = DialogModalityType::MODELESS; | |
diff --git a/xbmc/guilib/GUIWindow.cpp b/xbmc/guilib/GUIWindow.cpp | |
index a700ebe..8f7a408 100644 | |
--- a/xbmc/guilib/GUIWindow.cpp | |
+++ b/xbmc/guilib/GUIWindow.cpp | |
@@ -105,7 +105,7 @@ bool CGUIWindow::Load(const std::string& strFileName, bool bContainsPath) | |
break; | |
} | |
CLog::Log(LOGINFO, "Loading skin file: %s, load type: %s", strFileName.c_str(), strLoadType); | |
- | |
+ | |
// Find appropriate skin folder + resolution to load from | |
std::string strPath; | |
std::string strLowerPath; | |
@@ -157,7 +157,7 @@ bool CGUIWindow::Load(TiXmlElement* pRootElement) | |
{ | |
if (!pRootElement) | |
return false; | |
- | |
+ | |
if (strcmpi(pRootElement->Value(), "window")) | |
{ | |
CLog::Log(LOGERROR, "file : XML file doesnt contain <window>"); | |
@@ -541,7 +541,7 @@ bool CGUIWindow::OnMessage(CGUIMessage& message) | |
return true; | |
} | |
break; | |
- | |
+ | |
case GUI_MSG_WINDOW_INIT: | |
{ | |
CLog::Log(LOGDEBUG, "------ Window Init (%s) ------", GetProperty("xmlfile").c_str()); | |
@@ -574,7 +574,7 @@ bool CGUIWindow::OnMessage(CGUIMessage& message) | |
} | |
break; | |
} | |
- | |
+ | |
case GUI_MSG_UNFOCUS_ALL: | |
{ | |
//unfocus the current focused control in this window | |
@@ -788,7 +788,7 @@ void CGUIWindow::ClearAll() | |
bool CGUIWindow::Initialize() | |
{ | |
- if (!g_windowManager.Initialized()) | |
+ if (!g_windowManager.Initialized() || g_application.IsHeadless()) | |
return false; // can't load if we have no skin yet | |
if(!NeedXMLReload()) | |
return true; | |
diff --git a/xbmc/settings/SettingConditions.cpp b/xbmc/settings/SettingConditions.cpp | |
index c313bd0..41eb711 100644 | |
--- a/xbmc/settings/SettingConditions.cpp | |
+++ b/xbmc/settings/SettingConditions.cpp | |
@@ -270,6 +270,9 @@ void CSettingConditions::Initialize() | |
if (g_application.IsStandAlone()) | |
m_simpleConditions.insert("isstandalone"); | |
+ if (g_application.IsHeadless()) | |
+ m_simpleConditions.insert("is_headless"); | |
+ | |
if(CAEFactory::SupportsQualitySetting()) | |
m_simpleConditions.insert("has_ae_quality_levels"); | |
diff --git a/xbmc/xbmc.cpp b/xbmc/xbmc.cpp | |
index 57d2158..25cdd6d 100644 | |
--- a/xbmc/xbmc.cpp | |
+++ b/xbmc/xbmc.cpp | |
@@ -70,7 +70,7 @@ extern "C" int XBMC_Run(bool renderGUI) | |
g_RBP.LogFirmwareVerison(); | |
#endif | |
- if (renderGUI && !g_application.CreateGUI()) | |
+ if (renderGUI && !g_application.IsHeadless() && !g_application.CreateGUI()) | |
{ | |
fprintf(stderr, "ERROR: Unable to create GUI. Exiting\n"); | |
return status; | |
-- | |
1.7.9.5 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment