/*\r
-* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
+* Copyright 2013 Sveriges Television AB http://casparcg.com/\r
*\r
* This file is part of CasparCG (www.casparcg.com).\r
*\r
#include <modules/flash/flash.h>\r
#include <modules/ffmpeg/ffmpeg.h>\r
#include <modules/image/image.h>\r
+#include <modules/newtek/util/air_send.h>\r
\r
#include <common/env.h>\r
#include <common/exception/win32_exception.h>\r
CASPAR_LOG(info) << L"FFMPEG-swscale " << caspar::ffmpeg::get_swscale_version();\r
CASPAR_LOG(info) << L"Flash " << caspar::flash::get_version();\r
CASPAR_LOG(info) << L"Template-Host " << caspar::flash::get_cg_version();\r
+ CASPAR_LOG(info) << L"NewTek iVGA " << (caspar::newtek::airsend::is_available() ? L"available" : L"unavailable (" + caspar::newtek::airsend::dll_name() + L")");\r
}\r
\r
LONG WINAPI UserUnhandledExceptionFilter(EXCEPTION_POINTERS* info)\r
return EXCEPTION_EXECUTE_HANDLER;\r
}\r
\r
-void make_upper_case(std::wstring& str)\r
+std::wstring make_upper_case(const std::wstring& str)\r
{\r
- boost::to_upper(str);\r
+ return boost::to_upper_copy(str);\r
}\r
\r
int main(int argc, wchar_t* argv[])\r
SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);\r
\r
// Install structured exception handler.\r
- caspar::win32_exception::install_handler();\r
+ caspar::win32_exception::ensure_handler_installed_for_thread("main-thread");\r
\r
// Increase time precision. This will increase accuracy of function like Sleep(1) from 10 ms to 1 ms.\r
struct inc_prec\r
tbb_thread_installer(){observe(true);}\r
void on_scheduler_entry(bool is_worker)\r
{\r
- //caspar::detail::SetThreadName(GetCurrentThreadId(), "tbb-worker-thread");\r
- caspar::win32_exception::install_handler();\r
+ caspar::win32_exception::ensure_handler_installed_for_thread("tbb-worker-thread");\r
}\r
} tbb_thread_installer;\r
\r
+ bool restart = false;\r
tbb::task_scheduler_init init;\r
\r
try \r
boost::property_tree::xml_writer_settings<wchar_t> w(' ', 3);\r
boost::property_tree::write_xml(str, caspar::env::properties(), w);\r
CASPAR_LOG(info) << L"casparcg.config:\n-----------------------------------------\n" << str.str().c_str() << L"-----------------------------------------";\r
- bool wait_for_keypress;\r
+ tbb::atomic<bool> wait_for_keypress;\r
+ wait_for_keypress = false;\r
\r
{\r
boost::promise<bool> shutdown_server_now;\r
\r
// Use separate thread for the blocking console input, will be terminated \r
// anyway when the main thread terminates.\r
- boost::thread stdin_thread([&caspar_server, &shutdown_server_now]\r
+ boost::thread stdin_thread([&caspar_server, &shutdown_server_now, &wait_for_keypress]\r
{\r
+ caspar::win32_exception::ensure_handler_installed_for_thread("stdin-thread");\r
+\r
// Create a amcp parser for console commands.\r
caspar::protocol::amcp::AMCPProtocolStrategy amcp(\r
caspar_server.get_channels(),\r
caspar_server.get_thumbnail_generator(),\r
+ caspar_server.get_media_info_repo(),\r
shutdown_server_now);\r
\r
// Create a dummy client which prints amcp responses to console.\r
std::getline(std::wcin, wcmd); // TODO: It's blocking...\r
\r
//boost::to_upper(wcmd); // TODO COMPILER crashes on this line, Strange!\r
- make_upper_case(wcmd);\r
+ auto upper_cmd = make_upper_case(wcmd);\r
\r
- if(wcmd == L"EXIT" || wcmd == L"Q" || wcmd == L"QUIT" || wcmd == L"BYE")\r
+ if(upper_cmd == L"EXIT" || upper_cmd == L"Q" || upper_cmd == L"QUIT" || upper_cmd == L"BYE")\r
{\r
- shutdown_server_now.set_value(true); // True to wait for keypress\r
+ wait_for_keypress = true;\r
+ shutdown_server_now.set_value(false); // False to not restart server\r
break;\r
}\r
\r
L"PLAY 2-2 " + file + L" LOOP\r\n" \r
L"PLAY 2-3 " + file + L" LOOP\r\n";\r
}\r
- else if(wcmd.substr(0, 1) == L"X")\r
+ else if(upper_cmd.substr(0, 1) == L"X")\r
{\r
int num = 0;\r
std::wstring file;\r
} \r
});\r
stdin_thread.detach();\r
- wait_for_keypress = shutdown_server.get();\r
+ restart = shutdown_server.get();\r
}\r
Sleep(500);\r
CASPAR_LOG(info) << "Successfully shutdown CasparCG Server.";\r
Sleep(4000);\r
} \r
\r
- return 0;\r
+ return restart ? 5 : 0;\r
}
\ No newline at end of file