Merge pull request #5039 from CEikermann/patch-1
[vuplus_xbmc] / xbmc / xbmc.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "Application.h"
22 #include "settings/AdvancedSettings.h"
23
24 #ifdef TARGET_RASPBERRY_PI
25 #include "linux/RBP.h"
26 #endif
27
28 extern "C" int XBMC_Run(bool renderGUI)
29 {
30   int status = -1;
31
32   if (!g_advancedSettings.Initialized())
33   {
34 #ifdef _DEBUG
35   g_advancedSettings.m_logLevel     = LOG_LEVEL_DEBUG;
36   g_advancedSettings.m_logLevelHint = LOG_LEVEL_DEBUG;
37 #else
38   g_advancedSettings.m_logLevel     = LOG_LEVEL_NORMAL;
39   g_advancedSettings.m_logLevelHint = LOG_LEVEL_NORMAL;
40 #endif
41     g_advancedSettings.Initialize();
42   }
43
44   if (!g_application.Create())
45   {
46     fprintf(stderr, "ERROR: Unable to create application. Exiting\n");
47     return status;
48   }
49
50 #ifdef TARGET_RASPBERRY_PI
51   if(!g_RBP.Initialize())
52     return false;
53   g_RBP.LogFirmwareVerison();
54 #endif
55
56   if (renderGUI && !g_application.CreateGUI())
57   {
58     fprintf(stderr, "ERROR: Unable to create GUI. Exiting\n");
59     return status;
60   }
61   if (!g_application.Initialize())
62   {
63     fprintf(stderr, "ERROR: Unable to Initialize. Exiting\n");
64     return status;
65   }
66
67   try
68   {
69     status = g_application.Run();
70   }
71   catch(...)
72   {
73     fprintf(stderr, "ERROR: Exception caught on main loop. Exiting\n");
74     status = -1;
75   }
76
77 #ifdef TARGET_RASPBERRY_PI
78   g_RBP.Deinitialize();
79 #endif
80
81   return status;
82 }