From: ronag Date: Sun, 13 Nov 2011 19:48:32 +0000 (+0000) Subject: 2.0.2: console and diagnostics windows are closable. X-Git-Tag: 2.0.2~171 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=c0dd827a194f5fd3dabbdf39006a979d18c2b0a8;p=casparcg 2.0.2: console and diagnostics windows are closable. git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.2@1566 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d --- diff --git a/common/diagnostics/graph.cpp b/common/diagnostics/graph.cpp index 0b4348e0b..93ca5383e 100644 --- a/common/diagnostics/graph.cpp +++ b/common/diagnostics/graph.cpp @@ -112,7 +112,14 @@ private: return; sf::Event e; - while(window_->GetEvent(e)){} + while(window_->GetEvent(e)) + { + if(e.Type == sf::Event::Closed) + { + window_.reset(); + return; + } + } glClear(GL_COLOR_BUFFER_BIT); window_->Draw(*this); window_->Display(); diff --git a/modules/decklink/interop/DeckLinkAPI_h.h b/modules/decklink/interop/DeckLinkAPI_h.h index 1d1647214..4d0524e5a 100644 --- a/modules/decklink/interop/DeckLinkAPI_h.h +++ b/modules/decklink/interop/DeckLinkAPI_h.h @@ -4,7 +4,7 @@ /* File created by MIDL compiler version 7.00.0555 */ -/* at Fri Nov 11 23:52:26 2011 +/* at Sun Nov 13 20:29:25 2011 */ /* Compiler settings for interop\DeckLinkAPI.idl: Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 diff --git a/modules/decklink/interop/DeckLinkAPI_i.c b/modules/decklink/interop/DeckLinkAPI_i.c index ae524ec3b..2d1ed95f2 100644 --- a/modules/decklink/interop/DeckLinkAPI_i.c +++ b/modules/decklink/interop/DeckLinkAPI_i.c @@ -6,7 +6,7 @@ /* File created by MIDL compiler version 7.00.0555 */ -/* at Fri Nov 11 23:52:26 2011 +/* at Sun Nov 13 20:29:25 2011 */ /* Compiler settings for interop\DeckLinkAPI.idl: Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 diff --git a/shell/main.cpp b/shell/main.cpp index caa1b27a2..c55cd572f 100644 --- a/shell/main.cpp +++ b/shell/main.cpp @@ -66,6 +66,20 @@ #include +struct application_state +{ + enum type + { + running, + shutdown, + pause_and_shutdown + }; +}; + +boost::condition_variable shutdown_cond; +boost::mutex shutdown_mut; +tbb::atomic shutdown_event; + // NOTE: This is needed in order to make CComObject work since this is not a real ATL project. CComModule _AtlModule; extern __declspec(selectany) CAtlModule* _pAtlModule = &_AtlModule; @@ -79,13 +93,27 @@ void change_icon( const HICON hNewIcon ) ::FreeLibrary(hMod); } +BOOL WINAPI HandlerRoutine(__in DWORD dwCtrlType) +{ + switch(dwCtrlType) + { + case CTRL_CLOSE_EVENT: + case CTRL_SHUTDOWN_EVENT: + shutdown_event = application_state::shutdown; + shutdown_cond.notify_all(); + return true; + } + return false; +} + void setup_console_window() { auto hOut = GetStdHandle(STD_OUTPUT_HANDLE); // Disable close button in console to avoid shutdown without cleanup. - EnableMenuItem(GetSystemMenu(GetConsoleWindow(), FALSE), SC_CLOSE , MF_GRAYED); - DrawMenuBar(GetConsoleWindow()); + //EnableMenuItem(GetSystemMenu(GetConsoleWindow(), FALSE), SC_CLOSE , MF_GRAYED); + //DrawMenuBar(GetConsoleWindow()); + SetConsoleCtrlHandler(HandlerRoutine, true); // Configure console size and position. auto coord = GetLargestConsoleWindowSize(hOut); @@ -235,68 +263,91 @@ int main(int argc, wchar_t* argv[]) caspar::protocol::amcp::AMCPProtocolStrategy amcp(caspar_server.get_channels()); // Create a dummy client which prints amcp responses to console. - auto dummy = std::make_shared(); + auto console_client = std::make_shared(); - bool is_running = true; - while(is_running) + boost::thread input_thread([&] { - std::wstring wcmd; - std::getline(std::wcin, wcmd); // TODO: It's blocking... - - is_running = wcmd != L"exit" && wcmd != L"q"; - if(wcmd.substr(0, 1) == L"1") - wcmd = L"LOADBG 1-1 " + wcmd.substr(1, wcmd.length()-1) + L" SLIDE 100 LOOP \r\nPLAY 1-1"; - else if(wcmd.substr(0, 1) == L"2") - wcmd = L"MIXER 1-0 VIDEO IS_KEY 1"; - else if(wcmd.substr(0, 1) == L"3") - wcmd = L"CG 1-2 ADD 1 BBTELEFONARE 1"; - else if(wcmd.substr(0, 1) == L"4") - wcmd = L"PLAY 1-1 DV FILTER yadif=1:-1 LOOP"; - else if(wcmd.substr(0, 1) == L"5") - { - auto file = wcmd.substr(2, wcmd.length()-1); - wcmd = L"PLAY 1-1 " + file + L" LOOP\r\n" - L"PLAY 1-2 " + file + L" LOOP\r\n" - L"PLAY 1-3 " + file + L" LOOP\r\n" - L"PLAY 2-1 " + file + L" LOOP\r\n" - L"PLAY 2-2 " + file + L" LOOP\r\n" - L"PLAY 2-3 " + file + L" LOOP\r\n"; - } - else if(wcmd.substr(0, 1) == L"X") + while(shutdown_event == application_state::running) { - int num = 0; - std::wstring file; + std::wstring wcmd; + std::getline(std::wcin, wcmd); // TODO: It's blocking... + try { - num = boost::lexical_cast(wcmd.substr(1, 2)); - file = wcmd.substr(4, wcmd.length()-1); + if(wcmd == L"exit" || wcmd == L"q") + { + shutdown_event = application_state::pause_and_shutdown; + shutdown_cond.notify_all(); + return; + } + + // This is just dummy code for testing. + if(wcmd.substr(0, 1) == L"1") + wcmd = L"LOADBG 1-1 " + wcmd.substr(1, wcmd.length()-1) + L" SLIDE 100 LOOP \r\nPLAY 1-1"; + else if(wcmd.substr(0, 1) == L"2") + wcmd = L"MIXER 1-0 VIDEO IS_KEY 1"; + else if(wcmd.substr(0, 1) == L"3") + wcmd = L"CG 1-2 ADD 1 BBTELEFONARE 1"; + else if(wcmd.substr(0, 1) == L"4") + wcmd = L"PLAY 1-1 DV FILTER yadif=1:-1 LOOP"; + else if(wcmd.substr(0, 1) == L"5") + { + auto file = wcmd.substr(2, wcmd.length()-1); + wcmd = L"PLAY 1-1 " + file + L" LOOP\r\n" + L"PLAY 1-2 " + file + L" LOOP\r\n" + L"PLAY 1-3 " + file + L" LOOP\r\n" + L"PLAY 2-1 " + file + L" LOOP\r\n" + L"PLAY 2-2 " + file + L" LOOP\r\n" + L"PLAY 2-3 " + file + L" LOOP\r\n"; + } + else if(wcmd.substr(0, 1) == L"X") + { + int num = 0; + std::wstring file; + try + { + num = boost::lexical_cast(wcmd.substr(1, 2)); + file = wcmd.substr(4, wcmd.length()-1); + } + catch(...) + { + num = boost::lexical_cast(wcmd.substr(1, 1)); + file = wcmd.substr(3, wcmd.length()-1); + } + + int n = 0; + int num2 = num; + while(num2 > 0) + { + num2 >>= 1; + n++; + } + + wcmd = L"MIXER 1 GRID " + boost::lexical_cast(n); + + for(int i = 1; i <= num; ++i) + wcmd += L"\r\nPLAY 1-" + boost::lexical_cast(i) + L" " + file + L" LOOP";// + L" SLIDE 100 LOOP"; + } + + wcmd += L"\r\n"; + amcp.Parse(wcmd.c_str(), wcmd.length(), console_client); } catch(...) { - num = boost::lexical_cast(wcmd.substr(1, 1)); - file = wcmd.substr(3, wcmd.length()-1); - } - - int n = 0; - int num2 = num; - while(num2 > 0) - { - num2 >>= 1; - n++; + CASPAR_LOG_CURRENT_EXCEPTION(); } - - wcmd = L"MIXER 1 GRID " + boost::lexical_cast(n); - - for(int i = 1; i <= num; ++i) - wcmd += L"\r\nPLAY 1-" + boost::lexical_cast(i) + L" " + file + L" LOOP";// + L" SLIDE 100 LOOP"; } + }); - wcmd += L"\r\n"; - amcp.Parse(wcmd.c_str(), wcmd.length(), dummy); - } - } - Sleep(200); // CAPSAR_LOG is asynchronous. Try to get text in correct order. - system("pause"); + boost::unique_lock lock(shutdown_mut); + while(shutdown_event == application_state::running) + shutdown_cond.wait(lock); + } + + Sleep(200); // CAPSAR_LOG is asynchronous. Try to get text in correct order.' + + if(shutdown_event == application_state::pause_and_shutdown) + system("pause"); } catch(boost::property_tree::file_parser_error&) {