]> git.sesse.net Git - casparcg/blobdiff - shell/main.cpp
2.0. Whitespace fix.
[casparcg] / shell / main.cpp
index cfdd86cacd62f5b37f61c1600ca8fa7ecc878fee..d6404c0f9aba6bd1fe8255cd3f7a903eaddf3d40 100644 (file)
@@ -51,6 +51,7 @@
 #include <common/exception/win32_exception.h>\r
 #include <common/exception/exceptions.h>\r
 #include <common/log/log.h>\r
+#include <common/gl/gl_check.h>\r
 #include <common/os/windows/current_version.h>\r
 #include <common/os/windows/system_info.h>\r
 #include <common/utility/assert.h>\r
 #include <tbb/task_scheduler_init.h>\r
 \r
 #include <boost/foreach.hpp>\r
+#include <boost/property_tree/detail/file_parser_error.hpp>\r
 \r
 // NOTE: This is needed in order to make CComObject work since this is not a real ATL project.\r
 CComModule _AtlModule;\r
 extern __declspec(selectany) CAtlModule* _pAtlModule = &_AtlModule;\r
 \r
+void change_icon( const HICON hNewIcon )\r
+{\r
+   auto hMod = ::LoadLibrary(L"Kernel32.dll"); \r
+   typedef DWORD(__stdcall *SCI)(HICON);\r
+   auto pfnSetConsoleIcon = reinterpret_cast<SCI>(::GetProcAddress(hMod, "SetConsoleIcon")); \r
+   pfnSetConsoleIcon(hNewIcon); \r
+   ::FreeLibrary(hMod);\r
+}\r
+\r
 void setup_console_window()\r
 {       \r
        auto hOut = GetStdHandle(STD_OUTPUT_HANDLE);\r
@@ -82,7 +93,9 @@ void setup_console_window()
        DisplayArea.Right = coord.X-1;\r
        DisplayArea.Bottom = (coord.Y-1)/2;\r
        SetConsoleWindowInfo(hOut, TRUE, &DisplayArea);\r
-               \r
+                \r
+       change_icon(::LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(101)));\r
+\r
        // Set console title.\r
        std::wstringstream str;\r
        str << "CasparCG Server " << caspar::env::version();\r
@@ -129,6 +142,8 @@ int main(int argc, wchar_t* argv[])
 {      \r
        static_assert(sizeof(void*) == 4, "64-bit code generation is not supported.");\r
        \r
+       CASPAR_LOG(info) << L"Type \"q\" to close application";\r
+\r
        CASPAR_LOG(info) << L"THIS IS AN ALPHA BUILD";\r
 \r
        // Set debug mode.\r
@@ -156,7 +171,11 @@ int main(int argc, wchar_t* argv[])
        struct tbb_thread_installer : public tbb::task_scheduler_observer\r
        {\r
                tbb_thread_installer(){observe(true);}\r
-               void on_scheduler_entry(bool is_worker){caspar::win32_exception::install_handler();}\r
+               void on_scheduler_entry(bool is_worker)\r
+               {\r
+                       caspar::detail::SetThreadName(GetCurrentThreadId(), "tbb-worker-thread");\r
+                       caspar::win32_exception::install_handler();\r
+               }\r
        } tbb_thread_installer;\r
        \r
        try \r
@@ -201,7 +220,7 @@ int main(int argc, wchar_t* argv[])
                        else if(wcmd.substr(0, 1) == L"3")\r
                                wcmd = L"CG 1-2 ADD 1 BBTELEFONARE 1";\r
                        else if(wcmd.substr(0, 1) == L"4")\r
-                               wcmd = L"PLAY 1-1 DV SEEK 350 FILTER yadif=1:-1 LOOP";\r
+                               wcmd = L"PLAY 1-1 DV FILTER yadif=1:-1 LOOP";\r
                        else if(wcmd.substr(0, 1) == L"X")\r
                        {\r
                                int num = 0;\r
@@ -235,10 +254,20 @@ int main(int argc, wchar_t* argv[])
                        amcp.Parse(wcmd.c_str(), wcmd.length(), dummy);\r
                }\r
        }\r
+       catch(boost::property_tree::file_parser_error&)\r
+       {\r
+               CASPAR_LOG_CURRENT_EXCEPTION();\r
+               CASPAR_LOG(fatal) << L"Unhandled configuration error in main thread. Please check the configuration file (casparcg.config) for errors.";\r
+       }\r
+       catch(caspar::gl::ogl_exception&)\r
+       {\r
+               CASPAR_LOG_CURRENT_EXCEPTION();\r
+               CASPAR_LOG(fatal) << L"Unhandled OpenGL Error in main thread. Please try to update graphics drivers in order to receive full OpenGL 3.1+ Support.";\r
+       }\r
        catch(...)\r
        {\r
-               CASPAR_LOG(fatal) << "UNHANDLED EXCEPTION in main thread.";\r
                CASPAR_LOG_CURRENT_EXCEPTION();\r
+               CASPAR_LOG(fatal) << L"Unhandled exception in main thread. Please report this error on the CasparCG forums (www.casparcg.com/forum).";\r
        }       \r
        \r
        CASPAR_LOG(info) << "Successfully shutdown CasparCG Server.";\r