Merge pull request #1229 from alcoheca/upstream-playcounts
[vuplus_xbmc] / xbmc / xbmc.cpp
1 /*
2  *      Copyright (C) 2005-2008 Team XBMC
3  *      http://www.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, write to
17  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18  *  http://www.gnu.org/copyleft/gpl.html
19  *
20  */
21
22 #include "Application.h"
23 #include "settings/AdvancedSettings.h"
24
25 #ifdef TARGET_RASPBERRY_PI
26 #include "linux/RBP.h"
27 #endif
28
29 extern "C" int XBMC_Run(bool renderGUI)
30 {
31   int status = -1;
32
33   if (!g_advancedSettings.Initialized())
34   {
35 #ifdef _DEBUG
36   g_advancedSettings.m_logLevel     = LOG_LEVEL_DEBUG;
37   g_advancedSettings.m_logLevelHint = LOG_LEVEL_DEBUG;
38 #else
39   g_advancedSettings.m_logLevel     = LOG_LEVEL_NORMAL;
40   g_advancedSettings.m_logLevelHint = LOG_LEVEL_NORMAL;
41 #endif
42     g_advancedSettings.Initialize();
43   }
44
45   if (!g_application.Create())
46   {
47     fprintf(stderr, "ERROR: Unable to create application. Exiting\n");
48     return status;
49   }
50
51 #ifdef TARGET_RASPBERRY_PI
52   if(!g_RBP.Initialize())
53     return false;
54   g_RBP.LogFirmwareVerison();
55 #endif
56
57   if (renderGUI && !g_application.CreateGUI())
58   {
59     fprintf(stderr, "ERROR: Unable to create GUI. Exiting\n");
60     return status;
61   }
62   if (!g_application.Initialize())
63   {
64     fprintf(stderr, "ERROR: Unable to Initialize. Exiting\n");
65     return status;
66   }
67
68   try
69   {
70     status = g_application.Run(renderGUI);
71   }
72   catch(...)
73   {
74     fprintf(stderr, "ERROR: Exception caught on main loop. Exiting\n");
75     status = -1;
76   }
77
78 #ifdef TARGET_RASPBERRY_PI
79   g_RBP.Deinitialize();
80 #endif
81
82   return status;
83 }