Optimize automation-event process splitting
[ardour.git] / libs / pbd / pbd.cc
index cf7e523349cb7c84c08d35821d27ca0e7685cd38..a7a818ee5ffff8782c16451dc67e8bad39971c22 100644 (file)
 
 #ifdef PLATFORM_WINDOWS
 #include <winsock2.h>
+#include "pbd/windows_timer_utils.h"
+#include "pbd/windows_mmcss.h"
 #endif
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 extern void setup_libpbd_enums ();
 
@@ -48,8 +50,7 @@ namespace {
 
 static bool libpbd_initialized = false;
 
-}
-
+static
 void
 set_debug_options_from_env ()
 {
@@ -58,11 +59,32 @@ set_debug_options_from_env ()
 
        options = Glib::getenv ("PBD_DEBUG", set);
        if (set) {
-               std::cerr << "PBD_DEBUG=" << options << std::endl;
+               std::cerr << X_("PBD_DEBUG=") << options << std::endl;
                PBD::parse_debug_options (options.c_str());
        }
 }
 
+#ifdef PLATFORM_WINDOWS
+static
+void
+test_timers_from_env ()
+{
+       bool set;
+       std::string options;
+
+       options = Glib::getenv ("PBD_TEST_TIMERS", set);
+       if (set) {
+               if (!PBD::QPC::check_timer_valid ()) {
+                       PBD::error << X_("Windows QPC Timer source not usable") << endmsg;
+               } else {
+                       PBD::info << X_("Windows QPC Timer source usable") << endmsg;
+               }
+       }
+}
+#endif
+
+} // namespace
+
 bool
 PBD::init ()
 {
@@ -79,13 +101,20 @@ PBD::init ()
 
        /* Initialize windows socket DLL for PBD::CrossThreadChannel
         */
-       
+
        if (WSAStartup(MAKEWORD(1,1),&wsaData) != 0) {
-               fatal << "Windows socket initialization failed with error: " << WSAGetLastError() << endmsg;
-               abort();
-               /*NOTREACHED*/
+               error << X_("Windows socket initialization failed with error: ") << WSAGetLastError() << endmsg;
                return false;
        }
+
+       QPC::initialize();
+       test_timers_from_env ();
+
+       if (!PBD::MMCSS::initialize()) {
+               PBD::info << X_("Unable to initialize MMCSS") << endmsg;
+       } else {
+               PBD::info << X_("MMCSS Initialized") << endmsg;
+       }
 #endif
 
        if (!Glib::thread_supported()) {
@@ -108,8 +137,9 @@ void
 PBD::cleanup ()
 {
 #ifdef PLATFORM_WINDOWS
+       PBD::MMCSS::deinitialize ();
        WSACleanup();
-#endif 
+#endif
 
        EnumWriter::destroy ();
        FPU::destroy ();