X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fcross.cc;h=7c05ba2226182f39f9ec85d697899fe349cfbb44;hb=e068f8b19ed0892fed8da44b873e2d309d7ba137;hp=7996070982c84ec32b536d1decea82a20460bfb2;hpb=3828baf56467224f5d44049bf1e7a7ed11f43a05;p=dcpomatic.git diff --git a/src/lib/cross.cc b/src/lib/cross.cc index 799607098..7c05ba222 100644 --- a/src/lib/cross.cc +++ b/src/lib/cross.cc @@ -21,7 +21,11 @@ #include "cross.h" #include "compose.hpp" #include "log.h" +#include "config.h" #include "exceptions.h" +extern "C" { +#include +} #include #ifdef DCPOMATIC_LINUX #include @@ -31,6 +35,8 @@ #include #undef DATADIR #include +#include +#include #endif #ifdef DCPOMATIC_OSX #include @@ -377,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)); } @@ -396,3 +401,50 @@ start_batch_converter (boost::filesystem::path dcpomatic) CreateProcess (0, cmd, 0, 0, FALSE, 0, 0, 0, &startup_info, &process_info); #endif } + +uint64_t +thread_id () +{ +#ifdef DCPOMATIC_WINDOWS + return (uint64_t) GetCurrentThreadId (); +#else + return (uint64_t) pthread_self (); +#endif +} + +int +avio_open_boost (AVIOContext** s, boost::filesystem::path file, int flags) +{ +#ifdef DCPOMATIC_WINDOWS + int const length = (file.string().length() + 1) * 2; + char* utf8 = new char[length]; + WideCharToMultiByte (CP_UTF8, 0, file.c_str(), -1, utf8, length, 0, 0); + int const r = avio_open (s, utf8, flags); + delete[] utf8; + return r; +#else + 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