This repository has been archived by the owner on Mar 29, 2024. It is now read-only.
forked from wernerb/docker-xbmc-server
/
headless.patch
358 lines (335 loc) · 11.4 KB
/
headless.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
commit e477baa4a74f9f14c3b1ba5fbd57e049397a41db
Author: Celedhrim <celed+gitlab@ielf.org>
Date: Sun Jul 12 20:38:56 2015 +0200
headless patch
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..9f259b6 100644
--- a/xbmc/guilib/GUIDialog.cpp
+++ b/xbmc/guilib/GUIDialog.cpp
@@ -140,7 +140,7 @@ void CGUIDialog::UpdateVisibility()
else
Close();
}
-
+
if (m_autoClosing)
{ // check if our timer is running
if (!m_showStartTime)
@@ -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;