2 * Copyright (C) 2013-2015 Tim Mayberry <mojofunk@gmail.com>
3 * Copyright (C) 2014-2016 Paul Davis <paul@linuxaudiosystems.com>
4 * Copyright (C) 2014-2019 Robin Gareus <robin@gareus.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #ifdef PLATFORM_WINDOWS
31 #include <glibmm/thread.h>
34 #include "pbd/debug.h"
35 #include "pbd/error.h"
37 #include "pbd/enumwriter.h"
39 #include "pbd/xml++.h"
41 #ifdef PLATFORM_WINDOWS
43 #include "pbd/windows_timer_utils.h"
44 #include "pbd/windows_mmcss.h"
49 extern void setup_libpbd_enums ();
53 static bool libpbd_initialized = false;
57 set_debug_options_from_env ()
62 options = Glib::getenv ("PBD_DEBUG", set);
64 std::cerr << X_("PBD_DEBUG=") << options << std::endl;
65 PBD::parse_debug_options (options.c_str());
69 #ifdef PLATFORM_WINDOWS
72 test_timers_from_env ()
77 options = Glib::getenv ("PBD_TEST_TIMERS", set);
79 if (!PBD::QPC::check_timer_valid ()) {
80 PBD::error << X_("Windows QPC Timer source not usable") << endmsg;
82 PBD::info << X_("Windows QPC Timer source usable") << endmsg;
93 if (libpbd_initialized) {
97 #ifdef PLATFORM_WINDOWS
98 // Essential!! Make sure that any files used by Ardour
99 // will be created or opened in BINARY mode!
104 /* Initialize windows socket DLL for PBD::CrossThreadChannel
107 if (WSAStartup(MAKEWORD(1,1),&wsaData) != 0) {
108 error << X_("Windows socket initialization failed with error: ") << WSAGetLastError() << endmsg;
113 test_timers_from_env ();
115 if (!PBD::MMCSS::initialize()) {
116 PBD::info << X_("Unable to initialize MMCSS") << endmsg;
118 PBD::info << X_("MMCSS Initialized") << endmsg;
122 if (!Glib::thread_supported()) {
130 setup_libpbd_enums ();
132 set_debug_options_from_env ();
134 /* this call is made by any call to XMLTree::read() and its cousins. It
135 sets the handling of blank space to match the libxml2 standard,
136 rather than the libxml1 version. Without this, the behavior is
137 defined by whoever calls it first.
140 xmlKeepBlanksDefault (0);
142 libpbd_initialized = true;
149 #ifdef PLATFORM_WINDOWS
150 PBD::MMCSS::deinitialize ();
154 EnumWriter::destroy ();