Tidy up to use one list of servers.
[dcpomatic.git] / src / lib / cross.cc
index 831a1a2b2b0c2e1913646834d420c5e53c67b18c..7c05ba2226182f39f9ec85d697899fe349cfbb44 100644 (file)
@@ -21,6 +21,7 @@
 #include "cross.h"
 #include "compose.hpp"
 #include "log.h"
+#include "config.h"
 #include "exceptions.h"
 extern "C" {
 #include <libavformat/avio.h>
@@ -34,6 +35,8 @@ extern "C" {
 #include <windows.h>
 #undef DATADIR
 #include <shlwapi.h>
+#include <shellapi.h>
+#include <fcntl.h>
 #endif
 #ifdef DCPOMATIC_OSX
 #include <sys/sysctl.h>
@@ -380,7 +383,6 @@ start_batch_converter (boost::filesystem::path dcpomatic)
 #if defined(DCPOMATIC_LINUX) || defined(DCPOMATIC_OSX)
        pid_t pid = fork ();
        if (pid == 0) {
-               std::cout << "start " << batch << " from " << dcpomatic << "\n";
                int const r = system (batch.string().c_str());
                exit (WEXITSTATUS (r));
        }
@@ -424,3 +426,25 @@ avio_open_boost (AVIOContext** s, boost::filesystem::path file, int flags)
        return avio_open (s, file.c_str(), flags);
 #endif
 }
+
+#ifdef DCPOMATIC_WINDOWS
+void
+maybe_open_console ()
+{
+       if (Config::instance()->win32_console ()) {
+               AllocConsole();
+
+               HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);
+               int hCrt = _open_osfhandle((intptr_t) handle_out, _O_TEXT);
+               FILE* hf_out = _fdopen(hCrt, "w");
+               setvbuf(hf_out, NULL, _IONBF, 1);
+               *stdout = *hf_out;
+
+               HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE);
+               hCrt = _open_osfhandle((intptr_t) handle_in, _O_TEXT);
+               FILE* hf_in = _fdopen(hCrt, "r");
+               setvbuf(hf_in, NULL, _IONBF, 128);
+               *stdin = *hf_in;
+       }
+}
+#endif