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"
40 #ifdef PLATFORM_WINDOWS
42 #include "pbd/windows_timer_utils.h"
43 #include "pbd/windows_mmcss.h"
48 extern void setup_libpbd_enums ();
52 static bool libpbd_initialized = false;
56 set_debug_options_from_env ()
61 options = Glib::getenv ("PBD_DEBUG", set);
63 std::cerr << X_("PBD_DEBUG=") << options << std::endl;
64 PBD::parse_debug_options (options.c_str());
68 #ifdef PLATFORM_WINDOWS
71 test_timers_from_env ()
76 options = Glib::getenv ("PBD_TEST_TIMERS", set);
78 if (!PBD::QPC::check_timer_valid ()) {
79 PBD::error << X_("Windows QPC Timer source not usable") << endmsg;
81 PBD::info << X_("Windows QPC Timer source usable") << endmsg;
92 if (libpbd_initialized) {
96 #ifdef PLATFORM_WINDOWS
97 // Essential!! Make sure that any files used by Ardour
98 // will be created or opened in BINARY mode!
103 /* Initialize windows socket DLL for PBD::CrossThreadChannel
106 if (WSAStartup(MAKEWORD(1,1),&wsaData) != 0) {
107 error << X_("Windows socket initialization failed with error: ") << WSAGetLastError() << endmsg;
112 test_timers_from_env ();
114 if (!PBD::MMCSS::initialize()) {
115 PBD::info << X_("Unable to initialize MMCSS") << endmsg;
117 PBD::info << X_("MMCSS Initialized") << endmsg;
121 if (!Glib::thread_supported()) {
129 setup_libpbd_enums ();
131 set_debug_options_from_env ();
133 libpbd_initialized = true;
140 #ifdef PLATFORM_WINDOWS
141 PBD::MMCSS::deinitialize ();
145 EnumWriter::destroy ();