Guest User

2681 lines libs.diff as of 30 Oct 2025

a guest
Oct 30th, 2025
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 83.13 KB | None | 0 0
  1. diff --git a/libs/ardour/ardour/msvc_libardour.h b/libs/ardour/ardour/msvc_libardour.h
  2. index 06bbddf833..db0e5f5ba7 100644
  3. --- a/libs/ardour/ardour/msvc_libardour.h
  4. +++ b/libs/ardour/ardour/msvc_libardour.h
  5. @@ -50,7 +50,7 @@ extern "C" {
  6. #ifndef __THROW
  7. #define __THROW throw()
  8. #endif
  9. -#include <ardourext/sys/time.h>
  10. +#include <sys/time.h>
  11.  
  12. namespace ARDOUR {
  13.  
  14. diff --git a/libs/ardour/port_manager.cc b/libs/ardour/port_manager.cc
  15. index e5a160327e..d6b1f3f3ae 100644
  16. --- a/libs/ardour/port_manager.cc
  17. +++ b/libs/ardour/port_manager.cc
  18. @@ -22,7 +22,7 @@
  19. #include <vector>
  20.  
  21. #ifdef COMPILER_MSVC
  22. -#include <ardourext/misc.h>
  23. +#include <pbd/compat.h>
  24. #include <io.h> // Microsoft's nearest equivalent to <unistd.h>
  25. #else
  26. #include <regex.h>
  27. diff --git a/libs/pbd/base_ui.cc b/libs/pbd/base_ui.cc
  28. index b15a548cfa..30500c7ce8 100644
  29. --- a/libs/pbd/base_ui.cc
  30. +++ b/libs/pbd/base_ui.cc
  31. @@ -20,6 +20,25 @@
  32. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  33. */
  34.  
  35. +#ifdef _WIN32
  36. +#define NOMINMAX
  37. +#define WIN32_LEAN_AND_MEAN
  38. +#define NOMSG
  39. +#define NOGDI
  40. +#define NOUSER
  41. +#define NOSERVICE
  42. +#define NOSOUND
  43. +#define NOMCX
  44. +#include <windows.h>
  45. +#ifdef ERROR
  46. +#undef ERROR
  47. +#endif
  48. +#ifdef NO_ERROR
  49. +#undef NO_ERROR
  50. +#endif
  51. +#endif
  52. +
  53. +
  54. #include <cstring>
  55. #include <stdint.h>
  56. #ifdef COMPILER_MSVC
  57. @@ -62,7 +81,6 @@ BaseUI::BaseUI (const string& loop_name)
  58. , request_channel (true)
  59. {
  60. base_ui_instance = this;
  61. - request_channel.set_receive_handler (sigc::mem_fun (*this, &BaseUI::request_handler));
  62.  
  63. /* derived class must set _ok */
  64. }
  65. @@ -104,8 +122,8 @@ BaseUI::main_thread ()
  66. bool
  67. BaseUI::signal_running ()
  68. {
  69. - Glib::Threads::Mutex::Lock lm (_run_lock);
  70. - _running.signal ();
  71. + std::unique_lock<std::mutex> lm(_run_lock);
  72. + _running.notify_one();
  73.  
  74. return false; // don't call it again
  75. }
  76. @@ -120,9 +138,9 @@ BaseUI::run ()
  77. _main_loop = MainLoop::create (m_context);
  78. attach_request_source ();
  79.  
  80. - Glib::Threads::Mutex::Lock lm (_run_lock);
  81. + std::unique_lock<std::mutex> lm(_run_lock);
  82. _run_loop_thread = PBD::Thread::create (std::bind (&BaseUI::main_thread, this), string_compose ("UI:%1", event_loop_name ()));
  83. - _running.wait (_run_lock);
  84. + _running.wait(lm);
  85. }
  86.  
  87. void
  88. @@ -139,7 +157,7 @@ BaseUI::request_handler (Glib::IOCondition ioc)
  89. {
  90. /* check the request pipe */
  91.  
  92. - if (ioc & IO_IN) {
  93. + if (static_cast<int>(ioc) & static_cast<int>(Glib::IOCondition::IO_IN)) {
  94. request_channel.drain ();
  95.  
  96. /* there may been an error. we'd rather handle requests first,
  97. @@ -152,7 +170,7 @@ BaseUI::request_handler (Glib::IOCondition ioc)
  98. handle_ui_requests ();
  99. }
  100.  
  101. - if (ioc & ~(IO_IN|IO_PRI)) {
  102. + if (static_cast<int>(ioc) & ~(static_cast<int>(Glib::IOCondition::IO_IN)|static_cast<int>(Glib::IOCondition::IO_PRI))) {
  103. _main_loop->quit ();
  104. }
  105.  
  106. @@ -175,6 +193,7 @@ void
  107. BaseUI::attach_request_source ()
  108. {
  109. DEBUG_TRACE (DEBUG::EventLoop, string_compose ("%1: attach request source\n", event_loop_name()));
  110. + request_channel.set_receive_handler (sigc::mem_fun (*this, &BaseUI::request_handler));
  111. request_channel.attach (m_context);
  112. maybe_install_precall_handler (m_context);
  113. }
  114. diff --git a/libs/pbd/basename.cc b/libs/pbd/basename.cc
  115. index 97a3a3cecb..ee59adde07 100644
  116. --- a/libs/pbd/basename.cc
  117. +++ b/libs/pbd/basename.cc
  118. @@ -24,7 +24,7 @@ using Glib::ustring;
  119. ustring
  120. PBD::basename_nosuffix (ustring str)
  121. {
  122. - ustring base = Glib::path_get_basename (str);
  123. + std::string base = Glib::path_get_basename (str.raw());
  124.  
  125. return base.substr (0, base.find_last_of ('.'));
  126.  
  127. diff --git a/libs/pbd/boost_debug.cc b/libs/pbd/boost_debug.cc
  128. index c9a9f58a30..d6d508c2b7 100644
  129. --- a/libs/pbd/boost_debug.cc
  130. +++ b/libs/pbd/boost_debug.cc
  131. @@ -28,7 +28,7 @@
  132. #include <map>
  133. #include <set>
  134. #include <vector>
  135. -#include <glibmm/threads.h>
  136. +#include <mutex>
  137.  
  138. #include "pbd/stacktrace.h"
  139. #include "pbd/boost_debug.h"
  140. @@ -134,11 +134,11 @@ IPointerMap& interesting_pointers()
  141. return *_interesting_pointers;
  142. }
  143.  
  144. -static Glib::Threads::Mutex* _the_lock;
  145. -static Glib::Threads::Mutex& the_lock()
  146. +static std::mutex* _the_lock;
  147. +static std::mutex& the_lock()
  148. {
  149. if (_the_lock == 0) {
  150. - _the_lock = new Glib::Threads::Mutex;
  151. + _the_lock = new std::mutex;
  152. }
  153. return *_the_lock;
  154. }
  155. @@ -167,7 +167,7 @@ boost_debug_shared_ptr_show_live_debugging (bool yn)
  156. void
  157. boost_debug_shared_ptr_mark_interesting (void* ptr, const char* type)
  158. {
  159. - Glib::Threads::Mutex::Lock guard (the_lock());
  160. + std::lock_guard<std::mutex> guard(the_lock());
  161. pair<void*,const char*> newpair (ptr, type);
  162. interesting_pointers().insert (newpair);
  163. if (debug_out) {
  164. @@ -182,7 +182,7 @@ boost_debug_shared_ptr_operator_equals (void const *sp, void const *old_obj, int
  165. return;
  166. }
  167.  
  168. - Glib::Threads::Mutex::Lock guard (the_lock());
  169. + std::lock_guard<std::mutex> guard(the_lock());
  170.  
  171. if (is_interesting_object (old_obj) || is_interesting_object (obj)) {
  172. if (debug_out) {
  173. @@ -230,7 +230,7 @@ boost_debug_shared_ptr_reset (void const *sp, void const *old_obj, int old_use_c
  174. return;
  175. }
  176.  
  177. - Glib::Threads::Mutex::Lock guard (the_lock());
  178. + std::lock_guard<std::mutex> guard(the_lock());
  179.  
  180. if (is_interesting_object (old_obj) || is_interesting_object (obj)) {
  181. if (debug_out) {
  182. @@ -274,7 +274,7 @@ boost_debug_shared_ptr_reset (void const *sp, void const *old_obj, int old_use_c
  183. void
  184. boost_debug_shared_ptr_destructor (void const *sp, volatile void const *obj, int use_count)
  185. {
  186. - Glib::Threads::Mutex::Lock guard (the_lock());
  187. + std::lock_guard<std::mutex> guard(the_lock());
  188. PointerMap::iterator x = sptrs().find (sp);
  189.  
  190. if (x != sptrs().end()) {
  191. @@ -289,7 +289,7 @@ void
  192. boost_debug_shared_ptr_constructor (void const *sp, volatile void const *obj, int use_count)
  193. {
  194. if (is_interesting_object (obj)) {
  195. - Glib::Threads::Mutex::Lock guard (the_lock());
  196. + std::lock_guard<std::mutex> guard(the_lock());
  197. pair<void const*, SPDebug*> newpair;
  198.  
  199. newpair.first = sp;
  200. @@ -306,14 +306,14 @@ boost_debug_shared_ptr_constructor (void const *sp, volatile void const *obj, in
  201. void
  202. boost_debug_count_ptrs ()
  203. {
  204. - Glib::Threads::Mutex::Lock guard (the_lock());
  205. + std::lock_guard<std::mutex> guard(the_lock());
  206. // cerr << "Tracking " << interesting_pointers().size() << " interesting objects with " << sptrs().size () << " shared ptrs\n";
  207. }
  208.  
  209. void
  210. boost_debug_list_ptrs ()
  211. {
  212. - Glib::Threads::Mutex::Lock guard (the_lock());
  213. + std::lock_guard<std::mutex> guard(the_lock());
  214.  
  215. if (sptrs().empty()) {
  216. cerr << "There are no dangling shared ptrs\n";
  217. diff --git a/libs/pbd/cartesian.cc b/libs/pbd/cartesian.cc
  218. index 9f2a868309..a61ff2bc55 100644
  219. --- a/libs/pbd/cartesian.cc
  220. +++ b/libs/pbd/cartesian.cc
  221. @@ -20,6 +20,10 @@
  222.  
  223. #include "pbd/cartesian.h"
  224.  
  225. +#ifndef M_PI
  226. +#define M_PI 3.14159265358979323846
  227. +#endif
  228. +
  229. using namespace std;
  230.  
  231. void
  232. diff --git a/libs/pbd/ccurl.cc b/libs/pbd/ccurl.cc
  233. index 7c551357f0..5689ac2988 100644
  234. --- a/libs/pbd/ccurl.cc
  235. +++ b/libs/pbd/ccurl.cc
  236. @@ -128,13 +128,13 @@ CCurl::setup_certificate_paths ()
  237. */
  238. assert (!ca_path && !ca_info); // call once
  239.  
  240. - if (Glib::file_test ("/etc/pki/tls/certs/ca-bundle.crt", Glib::FILE_TEST_IS_REGULAR)) {
  241. + if (Glib::file_test ("/etc/pki/tls/certs/ca-bundle.crt", Glib::FileTest::IS_REGULAR)) {
  242. // Fedora / RHEL, Arch
  243. ca_info = "/etc/pki/tls/certs/ca-bundle.crt";
  244. - } else if (Glib::file_test ("/etc/ssl/certs/ca-certificates.crt", Glib::FILE_TEST_IS_REGULAR)) {
  245. + } else if (Glib::file_test ("/etc/ssl/certs/ca-certificates.crt", Glib::FileTest::IS_REGULAR)) {
  246. // Debian and derivatives
  247. ca_info = "/etc/ssl/certs/ca-certificates.crt";
  248. - } else if (Glib::file_test ("/etc/pki/tls/cert.pem", Glib::FILE_TEST_IS_REGULAR)) {
  249. + } else if (Glib::file_test ("/etc/pki/tls/cert.pem", Glib::FileTest::IS_REGULAR)) {
  250. // GNU/TLS can keep extra stuff here
  251. ca_info = "/etc/pki/tls/cert.pem";
  252. }
  253. diff --git a/libs/pbd/command.cc b/libs/pbd/command.cc
  254. index f120aeee4b..04fe3463d0 100644
  255. --- a/libs/pbd/command.cc
  256. +++ b/libs/pbd/command.cc
  257. @@ -21,6 +21,13 @@
  258. #include "pbd/command.h"
  259. #include "pbd/xml++.h"
  260.  
  261. +#undef read
  262. +#undef write
  263. +#undef close
  264. +#undef seek
  265. +#undef flush
  266. +
  267. +
  268. XMLNode &PBD::Command::get_state() const
  269. {
  270. XMLNode *node = new XMLNode ("Command");
  271. diff --git a/libs/pbd/controllable.cc b/libs/pbd/controllable.cc
  272. index c27a09bd6a..a0ab7e1e35 100644
  273. --- a/libs/pbd/controllable.cc
  274. +++ b/libs/pbd/controllable.cc
  275. @@ -29,6 +29,8 @@
  276.  
  277. #include "pbd/i18n.h"
  278.  
  279. +#include <shared_mutex>
  280. +
  281. using namespace PBD;
  282. using namespace std;
  283.  
  284. @@ -37,7 +39,7 @@ PBD::Signal<void(std::weak_ptr<PBD::Controllable> )> Controllable::StopLearning;
  285. PBD::Signal<void(std::weak_ptr<PBD::Controllable> )> Controllable::GUIFocusChanged;
  286. PBD::Signal<void(std::weak_ptr<PBD::Controllable> )> Controllable::ControlTouched;
  287.  
  288. -Glib::Threads::RWLock Controllable::registry_lock;
  289. +std::shared_mutex Controllable::registry_lock;
  290. Controllable::Controllables Controllable::registry;
  291. PBD::ScopedConnectionList Controllable::registry_connections;
  292.  
  293. @@ -116,7 +118,7 @@ Controllable::clear_flag (Flag f)
  294. void
  295. Controllable::add (Controllable& ctl)
  296. {
  297. - Glib::Threads::RWLock::WriterLock lm (registry_lock);
  298. + auto lm = std::unique_lock(registry_lock);
  299. registry.insert (&ctl);
  300. ctl.DropReferences.connect_same_thread (registry_connections, std::bind (&Controllable::remove, &ctl));
  301. ctl.Destroyed.connect_same_thread (registry_connections, std::bind (&Controllable::remove, &ctl));
  302. @@ -125,7 +127,7 @@ Controllable::add (Controllable& ctl)
  303. void
  304. Controllable::remove (Controllable* ctl)
  305. {
  306. - Glib::Threads::RWLock::WriterLock lm (registry_lock);
  307. + auto lm = std::unique_lock(registry_lock);
  308. Controllables::iterator i = std::find (registry.begin(), registry.end(), ctl);
  309. if (i != registry.end()) {
  310. registry.erase (i);
  311. @@ -135,7 +137,7 @@ Controllable::remove (Controllable* ctl)
  312. std::shared_ptr<Controllable>
  313. Controllable::by_id (const ID& id)
  314. {
  315. - Glib::Threads::RWLock::ReaderLock lm (registry_lock);
  316. + auto lm = std::shared_lock(registry_lock);
  317.  
  318. for (Controllables::iterator i = registry.begin(); i != registry.end(); ++i) {
  319. if ((*i)->id() == id) {
  320. @@ -149,7 +151,7 @@ ControllableSet
  321. Controllable::registered_controllables ()
  322. {
  323. ControllableSet rv;
  324. - Glib::Threads::RWLock::ReaderLock lm (registry_lock);
  325. + auto lm = std::shared_lock(registry_lock);
  326. for (auto const& i : registry) {
  327. try {
  328. rv.insert (i->shared_from_this ());
  329. @@ -164,7 +166,7 @@ Controllable::registered_controllables ()
  330. void
  331. Controllable::dump_registry ()
  332. {
  333. - Glib::Threads::RWLock::ReaderLock lm (registry_lock);
  334. + auto lm = std::shared_lock(registry_lock);
  335. if (registry.size() == 0) {
  336. return;
  337. }
  338. diff --git a/libs/pbd/cpus.cc b/libs/pbd/cpus.cc
  339. index f39c8a57de..70ce61a44a 100644
  340. --- a/libs/pbd/cpus.cc
  341. +++ b/libs/pbd/cpus.cc
  342. @@ -36,7 +36,7 @@
  343. #include "pbd/cpus.h"
  344.  
  345. #if defined(COMPILER_MSVC) && !defined(PTW32_VERSION)
  346. -#include <ardourext/pthread.h> // Gets us 'PTW32_VERSION'
  347. +#include <pthread.h> // Gets us 'PTW32_VERSION'
  348. #endif
  349.  
  350. int32_t
  351. diff --git a/libs/pbd/crossthread.cc b/libs/pbd/crossthread.cc
  352. index bf21d2befc..84e42e5320 100644
  353. --- a/libs/pbd/crossthread.cc
  354. +++ b/libs/pbd/crossthread.cc
  355. @@ -16,20 +16,20 @@
  356. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  357. */
  358.  
  359. +#ifndef PLATFORM_WINDOWS
  360. +#include <unistd.h>
  361. +#endif
  362.  
  363. #include <cstdlib>
  364. #include <cerrno>
  365. #include <cstring>
  366. #include <fcntl.h>
  367. -#include <unistd.h>
  368.  
  369. -#ifdef PLATFORM_WINDOWS
  370. -#include <winsock2.h>
  371. -#include <ws2tcpip.h>
  372. -#endif
  373. +#include <glibmm.h>
  374. +#include <giomm.h>
  375.  
  376. -#include "pbd/error.h"
  377. #include "pbd/crossthread.h"
  378. +#include "pbd/error.h"
  379.  
  380. using namespace std;
  381. using namespace PBD;
  382. @@ -41,28 +41,14 @@ using namespace Glib;
  383. #include "crossthread.win.cc"
  384. #endif
  385.  
  386. -#ifndef G_SOURCE_FUNC
  387. -#define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void)) (f))
  388. -#endif
  389. -
  390. -gboolean
  391. -cross_thread_channel_call_receive_slot (GIOChannel*, GIOCondition condition, void *data)
  392. -{
  393. - CrossThreadChannel* ctc = static_cast<CrossThreadChannel*>(data);
  394. - return ctc->receive_slot (Glib::IOCondition (condition));
  395. -}
  396. -
  397. -void
  398. -CrossThreadChannel::set_receive_handler (sigc::slot<bool,Glib::IOCondition> s)
  399. -{
  400. - receive_slot = s;
  401. -}
  402. -
  403. void
  404. CrossThreadChannel::attach (Glib::RefPtr<Glib::MainContext> context)
  405. {
  406. - receive_source = g_io_create_watch (receive_channel, GIOCondition(G_IO_IN | G_IO_ERR | G_IO_HUP));
  407. -
  408. - g_source_set_callback (receive_source, G_SOURCE_FUNC(cross_thread_channel_call_receive_slot), this, NULL);
  409. - g_source_attach (receive_source, context->gobj());
  410. + source = Gio::SocketSource::create (recv_socket,
  411. + static_cast<Glib::IOCondition>(G_IO_IN | G_IO_ERR | G_IO_HUP));
  412. + CrossThreadChannel* self = this;
  413. + source->connect ([self](Glib::IOCondition cond) -> bool {
  414. + return self->receive_slot (cond);
  415. + });
  416. + source->attach (context);
  417. }
  418. diff --git a/libs/pbd/crossthread.win.cc b/libs/pbd/crossthread.win.cc
  419. index 1d0758c911..f117e1ec80 100644
  420. --- a/libs/pbd/crossthread.win.cc
  421. +++ b/libs/pbd/crossthread.win.cc
  422. @@ -18,187 +18,53 @@
  423. */
  424.  
  425. CrossThreadChannel::CrossThreadChannel (bool non_blocking)
  426. - : receive_channel (0)
  427. - , receive_source (0)
  428. - , receive_slot ()
  429. - , send_socket()
  430. - , receive_socket()
  431. - , recv_address()
  432. + : receive_slot ()
  433. {
  434. - struct sockaddr_in send_address;
  435. + auto inet = Gio::InetAddress::create("127.0.0.1");
  436. + Gio::SocketFamily family = static_cast<Gio::SocketFamily>(G_SOCKET_FAMILY_IPV4);
  437. + Gio::Socket::Type type = static_cast<Gio::Socket::Type>(G_SOCKET_TYPE_DATAGRAM);
  438. + Gio::Socket::Protocol proto = static_cast<Gio::Socket::Protocol>(G_SOCKET_PROTOCOL_UDP);
  439.  
  440. - // Create Send Socket
  441. - send_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  442. - send_address.sin_family = AF_INET;
  443. - send_address.sin_addr.s_addr = inet_addr("127.0.0.1");
  444. - send_address.sin_port = htons(0);
  445. - int status = ::bind(send_socket, (SOCKADDR*)&send_address,
  446. - sizeof(send_address));
  447. + send_socket = Gio::Socket::create(family, type, proto);
  448. + recv_socket = Gio::Socket::create(family, type, proto);
  449.  
  450. - if (status != 0) {
  451. - std::cerr << "CrossThreadChannel::CrossThreadChannel() Send socket binding failed with error: " << WSAGetLastError() << std::endl;
  452. - return;
  453. - }
  454. + recv_socket->bind(Gio::InetSocketAddress::create(inet, 0), true);
  455.  
  456. - // make the socket non-blockable if required
  457. - u_long mode = (u_long)non_blocking;
  458. - int otp_result = 0;
  459. -
  460. - otp_result = ioctlsocket(send_socket, FIONBIO, &mode);
  461. - if (otp_result != NO_ERROR) {
  462. - std::cerr << "CrossThreadChannel::CrossThreadChannel() Send socket cannot be set to non blocking mode with error: " << WSAGetLastError() << std::endl;
  463. - }
  464. -
  465. - // Create Receive Socket, this socket will be set to unblockable mode by IO channel
  466. - receive_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  467. - recv_address.sin_family = AF_INET;
  468. - recv_address.sin_addr.s_addr = inet_addr("127.0.0.1");
  469. - recv_address.sin_port = htons(0);
  470. - status = ::bind(receive_socket, (SOCKADDR*)&recv_address,
  471. - sizeof(recv_address));
  472. -
  473. - if (status != 0) {
  474. - std::cerr << "CrossThreadChannel::CrossThreadChannel() Receive socket binding failed with error: " << WSAGetLastError() << std::endl;
  475. - return;
  476. - }
  477. -
  478. - // recieve socket will be made non-blocking by GSource which will use it
  479. -
  480. - // get assigned port number for Receive Socket
  481. - int recv_addr_len = sizeof(recv_address);
  482. - status = getsockname(receive_socket, (SOCKADDR*)&recv_address, &recv_addr_len);
  483. -
  484. - if (status != 0) {
  485. - std::cerr << "CrossThreadChannel::CrossThreadChannel() Setting receive socket address to local failed with error: " << WSAGetLastError() << std::endl;
  486. - return;
  487. - }
  488. -
  489. - // construct IOChannel
  490. - receive_channel = g_io_channel_win32_new_socket((gint)receive_socket);
  491. -
  492. - // set binary data type
  493. - GIOStatus g_status = g_io_channel_set_encoding (receive_channel, NULL, NULL);
  494. - if (G_IO_STATUS_NORMAL != g_status ) {
  495. - std::cerr << "CrossThreadChannel::CrossThreadChannel() Cannot set flag for IOChannel. " << g_status << std::endl;
  496. - return;
  497. - }
  498. -
  499. - // disable channel buffering
  500. - g_io_channel_set_buffered (receive_channel, false);
  501. -}
  502. -
  503. -CrossThreadChannel::~CrossThreadChannel ()
  504. -{
  505. - if (receive_source) {
  506. - /* this disconnects it from any main context it was attached in
  507. - in ::attach(), this prevent its callback from being invoked
  508. - after the destructor has finished.
  509. - */
  510. - g_source_destroy (receive_source);
  511. - }
  512. -
  513. - /* glibmm hack */
  514. -
  515. - if (receive_channel) {
  516. - g_io_channel_unref (receive_channel);
  517. - }
  518. -
  519. - closesocket(send_socket);
  520. - closesocket(receive_socket);
  521. + send_socket->set_blocking(!non_blocking);
  522. + recv_socket->set_blocking(!non_blocking);
  523. }
  524.  
  525. -void
  526. -CrossThreadChannel::wakeup ()
  527. +CrossThreadChannel::~CrossThreadChannel()
  528. {
  529. - char c = 0;
  530. -
  531. - // write one byte to wake up a thread which is listening our IOS
  532. - sendto(send_socket, &c, sizeof(c), 0, (SOCKADDR*)&recv_address, sizeof(recv_address) );
  533. + if (source)
  534. + source->destroy();
  535. }
  536.  
  537. void
  538. -CrossThreadChannel::drain ()
  539. +CrossThreadChannel::wakeup()
  540. {
  541. - /* flush the buffer - empty the channel from all requests */
  542. - GError *g_error = 0;
  543. - gchar buffer[512];
  544. - gsize read = 0;
  545. -
  546. - while (1) {
  547. - GIOStatus g_status = g_io_channel_read_chars (receive_channel, buffer, sizeof(buffer), &read, &g_error);
  548. -
  549. - if (G_IO_STATUS_AGAIN == g_status) {
  550. - break;
  551. - }
  552. -
  553. - if (G_IO_STATUS_NORMAL != g_status) {
  554. - std::cerr << "CrossThreadChannel::CrossThreadChannel() Cannot drain from read buffer! " << g_status << std::endl;
  555. -
  556. - if (g_error) {
  557. - std::cerr << "Error is Domain: " << g_error->domain << " Code: " << g_error->code << std::endl;
  558. - g_clear_error(&g_error);
  559. - } else {
  560. - std::cerr << "No error provided\n";
  561. - }
  562. - break;
  563. - }
  564. - }
  565. + char c = 0;
  566. + deliver(c);
  567. }
  568.  
  569. -
  570. int
  571. -CrossThreadChannel::deliver (char msg)
  572. +CrossThreadChannel::deliver(char msg)
  573. {
  574. -
  575. - // write one particular byte to wake up the thread which is listening our IOS
  576. - int status = sendto(send_socket, &msg, sizeof(msg), 0, (SOCKADDR*)&recv_address, sizeof(recv_address) );
  577. -
  578. - if (SOCKET_ERROR == status) {
  579. - return -1;
  580. - }
  581. -
  582. - return status;
  583. + auto addr = recv_socket->get_local_address();
  584. + gssize sent = send_socket->send_to(addr, &msg, sizeof(msg));
  585. + return (sent < 0) ? -1 : static_cast<int>(sent);
  586. }
  587.  
  588. -bool
  589. -CrossThreadChannel::poll_for_request()
  590. +int
  591. +CrossThreadChannel::receive(char& msg, bool /*wait*/)
  592. {
  593. - // windows before Vista has no poll
  594. - while(true) {
  595. - fd_set rfds;
  596. - FD_ZERO(&rfds);
  597. - FD_SET(receive_socket, &rfds);
  598. - if ((select(receive_socket+1, &rfds, NULL, NULL, NULL)) < 0) {
  599. - if (errno == EINTR) {
  600. - continue;
  601. - }
  602. - break;
  603. - }
  604. - if(FD_ISSET(receive_socket, &rfds)) {
  605. - return true;
  606. - }
  607. - }
  608. - return false;
  609. + gssize r = recv_socket->receive(&msg, sizeof(msg));
  610. + return (r < 0) ? -1 : static_cast<int>(r);
  611. }
  612.  
  613. -int
  614. -CrossThreadChannel::receive (char& msg, bool wait)
  615. +void
  616. +CrossThreadChannel::drain()
  617. {
  618. - gsize read = 0;
  619. - GError *g_error = 0;
  620. -
  621. - if (wait) {
  622. - if (!poll_for_request ()) {
  623. - return -1;
  624. - }
  625. - }
  626. -
  627. - // fetch the message from the channel.
  628. - GIOStatus g_status = g_io_channel_read_chars (receive_channel, &msg, sizeof(msg), &read, &g_error);
  629. -
  630. - if (G_IO_STATUS_NORMAL != g_status) {
  631. - read = -1;
  632. - }
  633. -
  634. - return read;
  635. + char buf[512];
  636. + while (recv_socket->receive(buf, sizeof(buf)) > 0) {}
  637. }
  638. diff --git a/libs/pbd/debug.cc b/libs/pbd/debug.cc
  639. index 2fcbc1f510..42434ef4be 100644
  640. --- a/libs/pbd/debug.cc
  641. +++ b/libs/pbd/debug.cc
  642. @@ -26,8 +26,11 @@
  643. #include <map>
  644. #include <vector>
  645. #include <algorithm>
  646. +#include <sstream>
  647.  
  648. -#include <boost/tokenizer.hpp>
  649. +#ifdef PLATFORM_WINDOWS
  650. +#define strncasecmp _strnicmp
  651. +#endif
  652.  
  653. #include "pbd/debug.h"
  654. #include "pbd/error.h"
  655. @@ -130,23 +133,26 @@ int
  656. PBD::parse_debug_options (const char* str)
  657. {
  658. string in_str = str;
  659. - typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
  660. - boost::char_separator<char> sep (",");
  661. - tokenizer tokens (in_str, sep);
  662. + std::vector<std::string> tokens;
  663. + std::stringstream ss(in_str);
  664. + std::string token;
  665. + while (std::getline(ss, token, ',')) {
  666. + tokens.push_back(token);
  667. + }
  668.  
  669. - for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter) {
  670. - if (*tok_iter == "list") {
  671. + for (auto const& tok : tokens) {
  672. + if (tok == "list") {
  673. list_debug_options ();
  674. return 1;
  675. }
  676.  
  677. - if (*tok_iter == "all") {
  678. + if (tok == "all") {
  679. debug_bits.set (); /* sets all bits */
  680. return 0;
  681. }
  682.  
  683. for (map<const char*,DebugBits>::iterator i = _debug_bit_map().begin(); i != _debug_bit_map().end(); ++i) {
  684. - const char* cstr = (*tok_iter).c_str();
  685. + const char* cstr = tok.c_str();
  686.  
  687. if (strncasecmp (cstr, i->first, strlen (cstr)) == 0) {
  688. debug_bits |= i->second;
  689. diff --git a/libs/pbd/downloader.cc b/libs/pbd/downloader.cc
  690. index 3986a796bc..f7e278403f 100644
  691. --- a/libs/pbd/downloader.cc
  692. +++ b/libs/pbd/downloader.cc
  693. @@ -69,13 +69,13 @@ Downloader::Downloader (string const & u, string const & dir)
  694. , _download_size (0)
  695. , _downloaded (0)
  696. {
  697. - if (!Glib::file_test (destdir, Glib::FILE_TEST_EXISTS)) {
  698. + if (!Glib::file_test (destdir, Glib::FileTest::EXISTS)) {
  699. if (g_mkdir_with_parents (destdir.c_str(), 0700) != 0) {
  700. error << string_compose (_("Could not create clip library dir %1 (%2)"), destdir, strerror(errno)) << endmsg;
  701. throw failed_constructor();
  702. }
  703. } else {
  704. - if (!Glib::file_test (destdir, Glib::FILE_TEST_IS_DIR)) {
  705. + if (!Glib::file_test (destdir, Glib::FileTest::IS_DIR)) {
  706. error << string_compose (_("Clip library dir (%1) is not a directory"), destdir) << endmsg;
  707. throw failed_constructor();
  708. }
  709. diff --git a/libs/pbd/event_loop.cc b/libs/pbd/event_loop.cc
  710. index a0dae62fef..01bc33ef44 100644
  711. --- a/libs/pbd/event_loop.cc
  712. +++ b/libs/pbd/event_loop.cc
  713. @@ -19,6 +19,7 @@
  714. */
  715.  
  716. #include <cstring>
  717. +#include <mutex>
  718.  
  719. #include <pthread.h>
  720.  
  721. @@ -33,11 +34,9 @@
  722. using namespace PBD;
  723. using namespace std;
  724.  
  725. -static void do_not_delete_the_loop_pointer (void*) { }
  726. +thread_local EventLoop* detail::EventLoopTLS::value = nullptr;
  727.  
  728. -Glib::Threads::Private<EventLoop> EventLoop::thread_event_loop (do_not_delete_the_loop_pointer);
  729. -
  730. -Glib::Threads::Mutex EventLoop::thread_buffer_requests_lock;
  731. +std::mutex EventLoop::thread_buffer_requests_lock;
  732. EventLoop::ThreadRequestBufferList EventLoop::thread_buffer_requests;
  733. EventLoop::RequestBufferSuppliers EventLoop::request_buffer_suppliers;
  734.  
  735. @@ -61,19 +60,22 @@ EventLoop::~EventLoop ()
  736. EventLoop*
  737. EventLoop::get_event_loop_for_thread()
  738. {
  739. - return thread_event_loop.get ();
  740. + return current_thread_event_loop();
  741. }
  742.  
  743. void
  744. EventLoop::set_event_loop_for_thread (EventLoop* loop)
  745. {
  746. - thread_event_loop.set (loop);
  747. + EventLoopTLS::value = loop;
  748. }
  749.  
  750. -void*
  751. -EventLoop::invalidate_request (void* data)
  752. +void
  753. +EventLoop::invalidate_request (sigc::notifiable* data)
  754. {
  755. - InvalidationRecord* ir = (InvalidationRecord*) data;
  756. + /* data points to the notifiable_base member, so we need to get back to the containing InvalidationRecord */
  757. + InvalidationRecord* ir = reinterpret_cast<InvalidationRecord*>(
  758. + reinterpret_cast<char*>(data) - offsetof(InvalidationRecord, notifiable_base)
  759. + );
  760.  
  761. /* Some of the requests queued with an EventLoop may involve functors
  762. * that make method calls to objects whose lifetime is shorter
  763. @@ -101,12 +103,10 @@ EventLoop::invalidate_request (void* data)
  764.  
  765. if (ir->event_loop) {
  766. DEBUG_TRACE (PBD::DEBUG::EventLoop, string_compose ("%1: invalidating request from %2 (%3) @ %4\n", pthread_name(), ir->event_loop, ir->event_loop->event_loop_name(), ir));
  767. - Glib::Threads::RWLock::WriterLock lm (ir->event_loop->slot_invalidation_rwlock());
  768. + WriteLock<RWMutex> lm (ir->event_loop->slot_invalidation_rwlock());
  769. ir->invalidate ();
  770. ir->event_loop->trash.push_back(ir);
  771. }
  772. -
  773. - return 0;
  774. }
  775.  
  776. /** Create a PBD::EventLoop::InvalidationRecord and attach a callback
  777. @@ -121,7 +121,7 @@ EventLoop::__invalidator (sigc::trackable& trackable, const char* file, int line
  778. ir->file = file;
  779. ir->line = line;
  780.  
  781. - trackable.add_destroy_notify_callback (ir, PBD::EventLoop::invalidate_request);
  782. + trackable.add_destroy_notify_callback (&ir->notifiable_base, PBD::EventLoop::invalidate_request);
  783.  
  784. return ir;
  785. }
  786. @@ -131,7 +131,7 @@ vector<EventLoop::ThreadBufferMapping>
  787. EventLoop::get_request_buffers_for_target_thread (const std::string& target_thread)
  788. {
  789. vector<ThreadBufferMapping> ret;
  790. - Glib::Threads::Mutex::Lock lm (thread_buffer_requests_lock);
  791. + std::lock_guard<std::mutex> lm (thread_buffer_requests_lock);
  792.  
  793. DEBUG_TRACE (PBD::DEBUG::EventLoop, string_compose ("%1 look for request buffers via %2\n", pthread_name(), target_thread));
  794.  
  795. @@ -160,7 +160,7 @@ EventLoop::pre_register (const string& emitting_thread_name, uint32_t num_reques
  796. */
  797.  
  798. ThreadBufferMapping mapping;
  799. - Glib::Threads::Mutex::Lock lm (thread_buffer_requests_lock);
  800. + std::lock_guard<std::mutex> lm (thread_buffer_requests_lock);
  801.  
  802. mapping.emitting_thread = pthread_self();
  803. mapping.num_requests = num_requests;
  804. @@ -206,7 +206,7 @@ EventLoop::pre_register (const string& emitting_thread_name, uint32_t num_reques
  805. void
  806. EventLoop::remove_request_buffer_from_map (pthread_t pth)
  807. {
  808. - Glib::Threads::Mutex::Lock lm (thread_buffer_requests_lock);
  809. + std::lock_guard<std::mutex> lm (thread_buffer_requests_lock);
  810.  
  811. for (ThreadRequestBufferList::iterator x = thread_buffer_requests.begin(); x != thread_buffer_requests.end(); ++x) {
  812. if (pthread_equal (x->emitting_thread, pth)) {
  813. diff --git a/libs/pbd/file_archive.cc b/libs/pbd/file_archive.cc
  814. index f26c7a26f1..99c3f64534 100644
  815. --- a/libs/pbd/file_archive.cc
  816. +++ b/libs/pbd/file_archive.cc
  817. @@ -27,6 +27,10 @@
  818. #include <fcntl.h>
  819. #include <sys/stat.h>
  820.  
  821. +#ifdef PLATFORM_WINDOWS
  822. +#include <io.h>
  823. +#endif
  824. +
  825. #include <glib.h>
  826. #include "pbd/gstdio_compat.h"
  827. #include <glibmm.h>
  828. @@ -89,7 +93,7 @@ get_url (void* arg)
  829. return NULL;
  830. }
  831.  
  832. -static ssize_t
  833. +static la_ssize_t
  834. ar_read (struct archive* a, void* d, const void** buff)
  835. {
  836. FileArchive::MemPipe* p = (FileArchive::MemPipe*)d;
  837. @@ -558,8 +562,13 @@ FileArchive::create (const std::map<std::string, std::string>& filemap, Compress
  838.  
  839. int fd = g_open (filepath, O_RDONLY, 0444);
  840. assert (fd >= 0);
  841. + int len;
  842.  
  843. - ssize_t len = read (fd, buf, sizeof (buf));
  844. +#ifdef PLATFORM_WINDOWS
  845. + len = _read (fd, buf, sizeof (buf));
  846. +#else
  847. + len = ::read (fd, buf, sizeof (buf));
  848. +#endif
  849. while (len > 0) {
  850. read_bytes += len;
  851. archive_write_data (a, buf, len);
  852. @@ -569,9 +578,17 @@ FileArchive::create (const std::map<std::string, std::string>& filemap, Compress
  853. break;
  854. }
  855. }
  856. - len = read (fd, buf, sizeof (buf));
  857. +#ifdef PLATFORM_WINDOWS
  858. + len = _read (fd, buf, sizeof (buf));
  859. +#else
  860. + len = ::read (fd, buf, sizeof (buf));
  861. +#endif
  862. }
  863. - close (fd);
  864. +#ifdef PLATFORM_WINDOWS
  865. + _close (fd);
  866. +#else
  867. + ::close (fd);
  868. +#endif
  869. if (_progress && _progress->cancelled ()) {
  870. break;
  871. }
  872. diff --git a/libs/pbd/file_utils.cc b/libs/pbd/file_utils.cc
  873. index aed050e694..5e9951def4 100644
  874. --- a/libs/pbd/file_utils.cc
  875. +++ b/libs/pbd/file_utils.cc
  876. @@ -53,8 +53,13 @@
  877.  
  878. /* close(), read(), write() */
  879. #ifdef COMPILER_MSVC
  880. -#include <io.h> // Microsoft's nearest equivalent to <unistd.h>
  881. -#include <ardourext/misc.h>
  882. +#include <io.h>
  883. +#include <stdlib.h>
  884. +#define PATH_MAX _MAX_PATH
  885. +#include <basetsd.h>
  886. +#include <windows.h>
  887. +#include <regex>
  888. +typedef SSIZE_T ssize_t;
  889. #else
  890. #include <unistd.h>
  891. #include <regex.h>
  892. @@ -92,7 +97,7 @@ run_functor_for_paths (vector<string>& result,
  893. DEBUG_TRACE (DEBUG::FileUtils,
  894. string_compose("Find files in expanded path: %1\n", expanded_path));
  895.  
  896. - if (!Glib::file_test (expanded_path, Glib::FILE_TEST_IS_DIR)) continue;
  897. + if (!Glib::file_test (expanded_path, Glib::FileTest::EXISTS)) continue;
  898.  
  899. Glib::Dir dir(expanded_path);
  900.  
  901. @@ -101,7 +106,7 @@ run_functor_for_paths (vector<string>& result,
  902. string fullpath = Glib::build_filename (expanded_path, *di);
  903. string basename = *di;
  904.  
  905. - bool is_dir = Glib::file_test (fullpath, Glib::FILE_TEST_IS_DIR);
  906. + bool is_dir = Glib::file_test (fullpath, Glib::FileTest::EXISTS);
  907.  
  908. if (is_dir && recurse) {
  909. if (scanned_paths.find (fullpath) == scanned_paths.end ()) {
  910. @@ -143,12 +148,12 @@ run_functor_for_paths (vector<string>& result,
  911. }
  912. catch (Glib::FileError const& err) {
  913. char errstr[PATH_MAX*2];
  914. - snprintf (errstr, sizeof (errstr), "Cannot access file: %s", err.what().c_str());
  915. + snprintf (errstr, sizeof (errstr), "Cannot access file: %s", err.what());
  916. warning << errstr << endmsg;
  917. }
  918. catch (Glib::ConvertError const& err) {
  919. char errstr[PATH_MAX*2];
  920. - snprintf (errstr, sizeof (errstr), "Cannot convert filename: %s", err.what().c_str());
  921. + snprintf (errstr, sizeof (errstr), "Cannot convert filename: %s", err.what());
  922. warning << errstr << endmsg;
  923. }
  924. }
  925. @@ -235,10 +240,10 @@ find_file (const Searchpath& search_path,
  926.  
  927. return true;
  928. }
  929. -
  930. +#ifndef COMPILER_MSVC
  931. static
  932. bool
  933. -regexp_filter (const string& str, void *arg)
  934. + regexp_filter (const string& str, void *arg)
  935. {
  936. regex_t* pattern = (regex_t*)arg;
  937. return regexec (pattern, str.c_str(), 0, 0, 0) == 0;
  938. @@ -252,7 +257,7 @@ find_files_matching_regex (vector<string>& result,
  939. {
  940. int err;
  941. char msg[256];
  942. - regex_t compiled_pattern;
  943. + std::regex compiled_pattern;
  944.  
  945. if ((err = regcomp (&compiled_pattern, regexp.c_str(),
  946. REG_EXTENDED|REG_NOSUB))) {
  947. @@ -274,10 +279,25 @@ find_files_matching_regex (vector<string>& result,
  948. find_files_matching_filter (result, paths,
  949. regexp_filter, &compiled_pattern,
  950. true, true, recurse);
  951. +}
  952. +#endif
  953.  
  954. - regfree (&compiled_pattern);
  955. +#ifdef COMPILER_MSVC
  956. +static
  957. +bool
  958. +regexp_filter (const string& str, void *arg)
  959. +{
  960. + const std::regex* pattern = static_cast<std::regex*>(arg);
  961. + return std::regex_search (str, *pattern);
  962. }
  963.  
  964. +void
  965. +find_files_matching_regex (vector<string>& result,
  966. + const Searchpath& paths,
  967. + const std::string& regexp,
  968. + bool recurse);
  969. +#endif
  970. +
  971. void
  972. find_paths_matching_filter (vector<string>& result,
  973. const Searchpath& paths,
  974. @@ -305,7 +325,7 @@ find_files_matching_filter (vector<string>& result,
  975. bool
  976. copy_file(const std::string & from_path, const std::string & to_path)
  977. {
  978. - if (!Glib::file_test (from_path, Glib::FILE_TEST_EXISTS)) return false;
  979. + if (!Glib::file_test (from_path, Glib::FileTest::EXISTS)) return false;
  980.  
  981. PBD::ScopedFileDescriptor fd_from (g_open (from_path.c_str(), O_RDONLY, 0444));
  982. PBD::ScopedFileDescriptor fd_to (g_open (to_path.c_str(), O_CREAT|O_TRUNC|O_RDWR, 0666));
  983. @@ -400,7 +420,7 @@ hard_link (const std::string& existing_file, const std::string& new_path)
  984. return false;
  985. # else
  986. /* see also ntfs_link -- msvc only pbd extension */
  987. - return CreateHardLinkA (new_path.c_str(), existing_file.c_str(), NULL);
  988. + return CreateHardLinkA (new_path.c_str(), existing_file.c_str(), nullptr) != 0;
  989. # endif
  990. #else
  991. return 0 == link (existing_file.c_str(), new_path.c_str());
  992. @@ -538,7 +558,7 @@ exists_and_writable (const std::string & p)
  993. * permissions permit access, the mount status does not.
  994. * access(2) seems like the best test for this.
  995. */
  996. - if (g_access (p.c_str(), W_OK) != 0) {
  997. + if (g_access (p.c_str(), 2) != 0) {
  998. DEBUG_TRACE (DEBUG::FileUtils, string_compose("exists_and_writable g_access '%1': !W_OK\n", p));
  999. return false;
  1000. }
  1001. @@ -611,7 +631,7 @@ tmp_writable_directory (const char* domain, const string& prefix)
  1002. oss << g_random_int ();
  1003. dir_name = oss.str();
  1004. new_test_dir = Glib::build_filename (tmp_dir, dir_name);
  1005. - if (Glib::file_test (new_test_dir, Glib::FILE_TEST_EXISTS)) continue;
  1006. + if (Glib::file_test (new_test_dir, Glib::FileTest::EXISTS)) continue;
  1007. } while (g_mkdir_with_parents (new_test_dir.c_str(), 0755) != 0);
  1008. return new_test_dir;
  1009. }
  1010. @@ -619,7 +639,7 @@ tmp_writable_directory (const char* domain, const string& prefix)
  1011. int
  1012. toggle_file_existence (string const & path)
  1013. {
  1014. - if (Glib::file_test (path, Glib::FILE_TEST_IS_REGULAR)) {
  1015. + if (Glib::file_test (path, Glib::FileTest::EXISTS)) {
  1016. return g_unlink (path.c_str());
  1017. }
  1018.  
  1019. diff --git a/libs/pbd/history_owner.cc b/libs/pbd/history_owner.cc
  1020. index 362b717ae2..887730879e 100644
  1021. --- a/libs/pbd/history_owner.cc
  1022. +++ b/libs/pbd/history_owner.cc
  1023. @@ -1,6 +1,8 @@
  1024. #include <string>
  1025. #include <vector>
  1026.  
  1027. +#include <chrono>
  1028. +#include <ctime>
  1029. #include "pbd/command.h"
  1030. #include "pbd/compose.h"
  1031. #include "pbd/debug.h"
  1032. @@ -165,7 +167,18 @@ HistoryOwner::commit_reversible_command (Command *cmd)
  1033. return;
  1034. }
  1035.  
  1036. - gettimeofday (&now, 0);
  1037. + // portable replacement for gettimeofday
  1038. + auto tp = std::chrono::system_clock::now();
  1039. + auto secs = std::chrono::system_clock::to_time_t(tp);
  1040. + auto us = std::chrono::duration_cast<std::chrono::microseconds>(
  1041. + tp.time_since_epoch()) % 1000000;
  1042. + now = {static_cast<long>(secs), static_cast<long>(us.count())};
  1043. +
  1044. +
  1045. +
  1046. +
  1047. +
  1048. +
  1049. _current_trans->set_timestamp (now);
  1050.  
  1051. DEBUG_TRACE (DEBUG::UndoHistory,
  1052. diff --git a/libs/pbd/id.cc b/libs/pbd/id.cc
  1053. index 79bc9cd4de..0aaf8877eb 100644
  1054. --- a/libs/pbd/id.cc
  1055. +++ b/libs/pbd/id.cc
  1056. @@ -24,20 +24,22 @@
  1057.  
  1058. #include "pbd/id.h"
  1059. #include "pbd/string_convert.h"
  1060. -
  1061. +#include <mutex>
  1062. #include <string>
  1063.  
  1064. using namespace std;
  1065. using namespace PBD;
  1066.  
  1067. -Glib::Threads::Mutex* ID::counter_lock = 0;
  1068. +static std::mutex* cxx_mutex = nullptr;
  1069. +GMutex* ID::counter_lock = nullptr;
  1070. uint64_t ID::_counter = 0;
  1071.  
  1072. void
  1073. ID::init ()
  1074. {
  1075. if (!counter_lock) {
  1076. - counter_lock = new Glib::Threads::Mutex;
  1077. + cxx_mutex = new std::mutex;
  1078. + counter_lock = reinterpret_cast<GMutex*>(cxx_mutex);
  1079. }
  1080. }
  1081.  
  1082. @@ -66,7 +68,7 @@ ID::ID (uint64_t n)
  1083. void
  1084. ID::reset ()
  1085. {
  1086. - Glib::Threads::Mutex::Lock lm (*counter_lock);
  1087. + std::lock_guard<std::mutex> g (*cxx_mutex);
  1088. _id = ++_counter;
  1089. }
  1090.  
  1091. diff --git a/libs/pbd/msvc/msvc_pbd.cc b/libs/pbd/msvc/msvc_pbd.cc
  1092. index 730672a31d..2c322d7319 100644
  1093. --- a/libs/pbd/msvc/msvc_pbd.cc
  1094. +++ b/libs/pbd/msvc/msvc_pbd.cc
  1095. @@ -34,8 +34,8 @@ CreateHardLinkA( LPCSTR lpFileName,
  1096. #include <stdlib.h>
  1097. #include <sys/stat.h>
  1098. #include <pbd/error.h>
  1099. -#include <ardourext/misc.h>
  1100. -#include <ardourext/pthread.h> // Should ensure that we include the right
  1101. +#include <pbd/compat.h>
  1102. +#include <pthread.h> // Should ensure that we include the right
  1103. // version - but we'll check anyway, later
  1104.  
  1105. #include <glibmm.h>
  1106. diff --git a/libs/pbd/pathexpand.cc b/libs/pbd/pathexpand.cc
  1107. index 4aba783b5d..6876a85fa3 100644
  1108. --- a/libs/pbd/pathexpand.cc
  1109. +++ b/libs/pbd/pathexpand.cc
  1110. @@ -25,7 +25,7 @@
  1111. #include <cerrno>
  1112. #include <cstdlib>
  1113.  
  1114. -#include <regex.h>
  1115. +#include <glibmm/regex.h>
  1116.  
  1117. #include <glibmm/fileutils.h>
  1118. #include <glibmm/miscutils.h>
  1119. @@ -62,46 +62,34 @@ PBD::path_expand (string path)
  1120.  
  1121. /* now do $VAR substitution, since wordexp isn't reliable */
  1122.  
  1123. - regex_t compiled_pattern;
  1124. - const int nmatches = 100;
  1125. - regmatch_t matches[nmatches];
  1126. + Glib::RefPtr<Glib::Regex> re = Glib::Regex::create (
  1127. + "\\$([a-zA-Z_][a-zA-Z0-9_]*|\\{[a-zA-Z_][a-zA-Z0-9_]*\\})");
  1128.  
  1129. - if (regcomp (&compiled_pattern, "\\$([a-zA-Z_][a-zA-Z0-9_]*|\\{[a-zA-Z_][a-zA-Z0-9_]*\\})", REG_EXTENDED)) {
  1130. - std::cerr << "bad regcomp\n";
  1131. - return path;
  1132. - }
  1133. -
  1134. - while (true) {
  1135. -
  1136. - if (regexec (&compiled_pattern, path.c_str(), nmatches, matches, 0)) {
  1137. + Glib::ustring u_path = path;
  1138. + Glib::MatchInfo mi;
  1139. + while (re->match (u_path, mi, Glib::Regex::MatchFlags::DEFAULT)) {
  1140. + Glib::ustring match = mi.fetch (0);
  1141. + if (match.empty())
  1142. break;
  1143. - }
  1144. -
  1145. - /* matches[0] gives the entire match */
  1146. -
  1147. - string match = path.substr (matches[0].rm_so, matches[0].rm_eo - matches[0].rm_so);
  1148. -
  1149. +
  1150. /* try to get match from the environment */
  1151. -
  1152. - if (match[1] == '{') {
  1153. - /* ${FOO} form */
  1154. - match = match.substr (2, match.length() - 3);
  1155. - }
  1156. -
  1157. - char* matched_value = getenv (match.c_str());
  1158. -
  1159. - if (matched_value) {
  1160. - path.replace (matches[0].rm_so, matches[0].rm_eo - matches[0].rm_so, matched_value);
  1161. - } else {
  1162. - path.replace (matches[0].rm_so, matches[0].rm_eo - matches[0].rm_so, string());
  1163. - }
  1164. -
  1165. - /* go back and do it again with whatever remains after the
  1166. - * substitution
  1167. - */
  1168. - }
  1169. -
  1170. - regfree (&compiled_pattern);
  1171. + if (match[1] == '{') {
  1172. + /* ${FOO} form */
  1173. + match = match.substr (2, match.bytes() - 3);
  1174. + }
  1175. +
  1176. + char* matched_value = getenv (match.raw().c_str());
  1177. +
  1178. + gint start = 0, end = 0;
  1179. + mi.fetch_pos (0, start, end);
  1180. +
  1181. + if (matched_value)
  1182. + path.replace (start, end - start, matched_value);
  1183. + else
  1184. + path.replace (start, end - start, string());
  1185. +
  1186. + u_path = path; // keep ustring in sync
  1187. + }
  1188.  
  1189. /* canonicalize */
  1190.  
  1191. @@ -158,7 +146,7 @@ PBD::parse_path(std::string path, bool check_if_exists)
  1192. {
  1193. dir = *i;
  1194. }
  1195. - if (!check_if_exists || Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) {
  1196. + if (!check_if_exists || Glib::file_test (dir, Glib::FileTest::IS_DIR)) {
  1197. pathlist.push_back(dir);
  1198. }
  1199. }
  1200. diff --git a/libs/pbd/pbd.cc b/libs/pbd/pbd.cc
  1201. index c19af3e462..820b23d76e 100644
  1202. --- a/libs/pbd/pbd.cc
  1203. +++ b/libs/pbd/pbd.cc
  1204. @@ -28,8 +28,6 @@
  1205.  
  1206. #include <giomm.h>
  1207.  
  1208. -#include <glibmm/thread.h>
  1209. -
  1210. #include "pbd/pbd.h"
  1211. #include "pbd/ccurl.h"
  1212. #include "pbd/debug.h"
  1213. @@ -87,10 +85,6 @@ PBD::init ()
  1214. }
  1215. #endif
  1216.  
  1217. - if (!Glib::thread_supported()) {
  1218. - Glib::thread_init();
  1219. - }
  1220. -
  1221. Gio::init ();
  1222.  
  1223. PBD::ID::init ();
  1224. diff --git a/libs/pbd/pbd/abstract_ui.inc.cc b/libs/pbd/pbd/abstract_ui.inc.cc
  1225. index f3f735c973..4ab8f59e5c 100644
  1226. --- a/libs/pbd/pbd/abstract_ui.inc.cc
  1227. +++ b/libs/pbd/pbd/abstract_ui.inc.cc
  1228. @@ -33,7 +33,7 @@
  1229. #include "pbd/i18n.h"
  1230.  
  1231. #ifdef COMPILER_MSVC
  1232. -#include <ardourext/misc.h> // Needed for 'DECLARE_DEFAULT_COMPARISONS'. Objects in an STL container can be
  1233. +#include <pbd/compat.h> // Needed for 'DECLARE_DEFAULT_COMPARISONS'. Objects in an STL container can be
  1234. // searched and sorted. Thus, when instantiating the container, MSVC complains
  1235. // if the type of object being contained has no appropriate comparison operators
  1236. // defined (specifically, if operators '<' and '==' are undefined). This seems
  1237. diff --git a/libs/pbd/pbd/base_ui.h b/libs/pbd/pbd/base_ui.h
  1238. index 23b35926f0..800846ed0d 100644
  1239. --- a/libs/pbd/pbd/base_ui.h
  1240. +++ b/libs/pbd/pbd/base_ui.h
  1241. @@ -20,14 +20,20 @@
  1242.  
  1243. #pragma once
  1244.  
  1245. +#ifdef _WIN32
  1246. +#define NOMINMAX
  1247. +#define WIN32_LEAN_AND_MEAN
  1248. +#endif
  1249. +
  1250. #include <string>
  1251. #include <stdint.h>
  1252.  
  1253. #include <sigc++/slot.h>
  1254. #include <sigc++/trackable.h>
  1255.  
  1256. -#include <glibmm/threads.h>
  1257. #include <glibmm/main.h>
  1258. +#include <mutex>
  1259. +#include <condition_variable>
  1260.  
  1261. #include "pbd/libpbd_visibility.h"
  1262. #include "pbd/crossthread.h"
  1263. @@ -79,8 +85,8 @@ class LIBPBD_API BaseUI : public sigc::trackable, public PBD::EventLoop
  1264. Glib::RefPtr<Glib::MainLoop> _main_loop;
  1265. Glib::RefPtr<Glib::MainContext> m_context;
  1266. PBD::Thread* _run_loop_thread;
  1267. - Glib::Threads::Mutex _run_lock;
  1268. - Glib::Threads::Cond _running;
  1269. + std::mutex _run_lock;
  1270. + std::condition_variable _running;
  1271.  
  1272. /* this signals _running from within the event loop,
  1273. from an idle callback
  1274. diff --git a/libs/pbd/pbd/controllable.h b/libs/pbd/pbd/controllable.h
  1275. index 4cd0433d09..c700f00a93 100644
  1276. --- a/libs/pbd/pbd/controllable.h
  1277. +++ b/libs/pbd/pbd/controllable.h
  1278. @@ -25,10 +25,11 @@
  1279. #include <memory>
  1280. #include <string>
  1281. #include <set>
  1282. +#include <glib.h>
  1283. +#include <glibmm.h>
  1284.  
  1285. #include "pbd/libpbd_visibility.h"
  1286. #include "pbd/signals.h"
  1287. -#include <glibmm/threads.h>
  1288.  
  1289.  
  1290. #include "pbd/statefuldestructible.h"
  1291. @@ -191,7 +192,7 @@ private:
  1292. typedef std::set<PBD::Controllable*> Controllables;
  1293.  
  1294. static ScopedConnectionList registry_connections;
  1295. - static Glib::Threads::RWLock registry_lock;
  1296. + static std::shared_mutex registry_lock;
  1297. static Controllables registry;
  1298.  
  1299. static void add (Controllable&);
  1300. diff --git a/libs/pbd/pbd/crossthread.h b/libs/pbd/pbd/crossthread.h
  1301. index 08f61a5b58..f5eb328696 100644
  1302. --- a/libs/pbd/pbd/crossthread.h
  1303. +++ b/libs/pbd/pbd/crossthread.h
  1304. @@ -19,18 +19,29 @@
  1305.  
  1306. #pragma once
  1307.  
  1308. -#ifdef check
  1309. -#undef check
  1310. -#endif
  1311. -
  1312. -#include <glibmm/main.h>
  1313. -
  1314. #include "pbd/libpbd_visibility.h"
  1315.  
  1316. +#include <gio/gio.h>
  1317. +
  1318. #ifdef PLATFORM_WINDOWS
  1319. +#include <winsock2.h>
  1320. #include <windows.h>
  1321. +#undef check
  1322. +#undef read
  1323. +#undef write
  1324. +#undef close
  1325. +#undef seek
  1326. +#undef flush
  1327. +#undef interface
  1328. +#undef min
  1329. +#ifdef Flags
  1330. +#undef Flags
  1331. +#endif
  1332. +#undef max
  1333. #endif // PLATFORM_WINDOWS
  1334.  
  1335. +#include <glibmm/main.h>
  1336. +#include <giomm.h>
  1337.  
  1338. /** A simple abstraction of a mechanism of signalling one thread from another.
  1339. * The signaller calls \ref wakeup() to tell the signalled thread to check for
  1340. @@ -81,25 +92,26 @@ public:
  1341. */
  1342. void drain ();
  1343.  
  1344. - void set_receive_handler (sigc::slot<bool,Glib::IOCondition> s);
  1345. void attach (Glib::RefPtr<Glib::MainContext>);
  1346. + void set_receive_handler (sigc::slot<bool(Glib::IOCondition)> s) { receive_slot = s; }
  1347.  
  1348. private:
  1349. - friend gboolean cross_thread_channel_call_receive_slot (GIOChannel*, GIOCondition condition, void *data);
  1350. + sigc::slot<bool(Glib::IOCondition)> receive_slot;
  1351.  
  1352. +#ifndef PLATFORM_WINDOWS
  1353. + friend gboolean cross_thread_channel_call_receive_slot (GIOChannel*, GIOCondition condition, void *data);
  1354. GIOChannel* receive_channel;
  1355. GSource* receive_source;
  1356. - sigc::slot<bool,Glib::IOCondition> receive_slot;
  1357. +#endif
  1358.  
  1359. bool poll_for_request();
  1360.  
  1361. #ifndef PLATFORM_WINDOWS
  1362. int fds[2]; // current implementation uses a pipe/fifo
  1363. #else
  1364. -
  1365. - SOCKET send_socket;
  1366. - SOCKET receive_socket;
  1367. - struct sockaddr_in recv_address;
  1368. + Glib::RefPtr<Gio::Socket> send_socket;
  1369. + Glib::RefPtr<Gio::Socket> recv_socket;
  1370. + Glib::RefPtr<Gio::SocketSource> source;
  1371. #endif
  1372.  
  1373. };
  1374. diff --git a/libs/pbd/pbd/debug.h b/libs/pbd/pbd/debug.h
  1375. index 7efea83d11..7e51c474a5 100644
  1376. --- a/libs/pbd/pbd/debug.h
  1377. +++ b/libs/pbd/pbd/debug.h
  1378. @@ -31,7 +31,7 @@
  1379.  
  1380. /* check for PTW32_VERSION */
  1381. #ifdef COMPILER_MSVC
  1382. -#include <ardourext/pthread.h>
  1383. +#include <pthread.h>
  1384. #else
  1385. #include <pthread.h>
  1386. #endif
  1387. diff --git a/libs/pbd/pbd/event_loop.h b/libs/pbd/pbd/event_loop.h
  1388. index 31df5d5925..b7415cc6d2 100644
  1389. --- a/libs/pbd/pbd/event_loop.h
  1390. +++ b/libs/pbd/pbd/event_loop.h
  1391. @@ -25,13 +25,61 @@
  1392. #include <map>
  1393. #include <stdint.h>
  1394. #include <pthread.h>
  1395. -#include <glibmm/threads.h>
  1396. -
  1397. +#include <mutex>
  1398. +#include <sigc++/trackable.h>
  1399. +#include <functional>
  1400. #include "pbd/libpbd_visibility.h"
  1401. +#ifdef PLATFORM_WINDOWS
  1402. +#include <shared_mutex>
  1403. +#endif
  1404.  
  1405. namespace PBD
  1406. {
  1407.  
  1408. +#ifdef PLATFORM_WINDOWS
  1409. +using RWMutex = std::shared_mutex;
  1410. +template<typename Mutex>
  1411. +using ReadLock = std::shared_lock<Mutex>;
  1412. +template<typename Mutex>
  1413. +using WriteLock = std::unique_lock<Mutex>;
  1414. +#else
  1415. +// Wrapper for pthread_rwlock to maintain consistent behavior with glibmm-2.4
  1416. +class PThreadRWLock {
  1417. + pthread_rwlock_t _lock;
  1418. +public:
  1419. + PThreadRWLock() { pthread_rwlock_init(&_lock, nullptr); }
  1420. + ~PThreadRWLock() { pthread_rwlock_destroy(&_lock); }
  1421. + void lock() { pthread_rwlock_wrlock(&_lock); }
  1422. + void unlock() { pthread_rwlock_unlock(&_lock); }
  1423. + void lock_shared() { pthread_rwlock_rdlock(&_lock); }
  1424. + void unlock_shared() { pthread_rwlock_unlock(&_lock); }
  1425. + // Non-copyable
  1426. + PThreadRWLock(const PThreadRWLock&) = delete;
  1427. + PThreadRWLock& operator=(const PThreadRWLock&) = delete;
  1428. +};
  1429. +using RWMutex = PThreadRWLock;
  1430. +
  1431. +template<typename Mutex>
  1432. +class ReadLock {
  1433. + Mutex& _mutex;
  1434. +public:
  1435. + explicit ReadLock(Mutex& m) : _mutex(m) { _mutex.lock_shared(); }
  1436. + ~ReadLock() { _mutex.unlock_shared(); }
  1437. + ReadLock(const ReadLock&) = delete;
  1438. + ReadLock& operator=(const ReadLock&) = delete;
  1439. +};
  1440. +
  1441. +template<typename Mutex>
  1442. +class WriteLock {
  1443. + Mutex& _mutex;
  1444. +public:
  1445. + explicit WriteLock(Mutex& m) : _mutex(m) { _mutex.lock(); }
  1446. + ~WriteLock() { _mutex.unlock(); }
  1447. + WriteLock(const WriteLock&) = delete;
  1448. + WriteLock& operator=(const WriteLock&) = delete;
  1449. +};
  1450. +#endif
  1451. +
  1452. /** An EventLoop is as basic abstraction designed to be used with any "user
  1453. * interface" (not necessarily graphical) that needs to wait on
  1454. * events/requests and dispatch/process them as they arrive.
  1455. @@ -41,7 +89,15 @@ namespace PBD
  1456. * when something like this is needed (it inherits from EventLoop).
  1457. */
  1458.  
  1459. -class LIBPBD_API EventLoop
  1460. +class EventLoop;
  1461. +
  1462. +namespace detail {
  1463. +struct EventLoopTLS {
  1464. + static thread_local EventLoop* value;
  1465. +};
  1466. +}
  1467. +
  1468. +class LIBPBD_API EventLoop : private detail::EventLoopTLS
  1469. {
  1470. public:
  1471. EventLoop (std::string const&);
  1472. @@ -54,6 +110,7 @@ public:
  1473. struct BaseRequestObject;
  1474.  
  1475. struct InvalidationRecord {
  1476. + sigc::notifiable notifiable_base;
  1477. std::list<BaseRequestObject*> requests;
  1478. PBD::EventLoop* event_loop;
  1479. std::atomic<int> _valid;
  1480. @@ -71,7 +128,7 @@ public:
  1481. int use_count () { return _ref.load (); }
  1482. };
  1483.  
  1484. - static void* invalidate_request (void* data);
  1485. + static void invalidate_request (sigc::notifiable* data);
  1486.  
  1487. struct BaseRequestObject {
  1488. RequestType type;
  1489. @@ -87,7 +144,7 @@ public:
  1490. };
  1491.  
  1492. virtual bool call_slot (InvalidationRecord*, const std::function<void()>&) = 0;
  1493. - virtual Glib::Threads::RWLock& slot_invalidation_rwlock() = 0;
  1494. + virtual RWMutex& slot_invalidation_rwlock() = 0;
  1495.  
  1496. std::string event_loop_name() const { return _name; }
  1497.  
  1498. @@ -109,12 +166,14 @@ public:
  1499. static InvalidationRecord* __invalidator (sigc::trackable& trackable, const char*, int);
  1500.  
  1501. private:
  1502. - static Glib::Threads::Private<EventLoop> thread_event_loop;
  1503. + static EventLoop* current_thread_event_loop() {
  1504. + return EventLoopTLS::value;
  1505. + }
  1506. std::string _name;
  1507.  
  1508. typedef std::vector<ThreadBufferMapping> ThreadRequestBufferList;
  1509. static ThreadRequestBufferList thread_buffer_requests;
  1510. - static Glib::Threads::Mutex thread_buffer_requests_lock;
  1511. + static std::mutex thread_buffer_requests_lock;
  1512.  
  1513. struct RequestBufferSupplier {
  1514.  
  1515. diff --git a/libs/pbd/pbd/id.h b/libs/pbd/pbd/id.h
  1516. index cf8d571e51..bfe28ff9db 100644
  1517. --- a/libs/pbd/pbd/id.h
  1518. +++ b/libs/pbd/pbd/id.h
  1519. @@ -24,7 +24,7 @@
  1520. #include <stdint.h>
  1521. #include <string>
  1522.  
  1523. -#include <glibmm/threads.h>
  1524. +#include <glib.h>
  1525.  
  1526. #include "pbd/libpbd_visibility.h"
  1527.  
  1528. @@ -70,7 +70,7 @@ class LIBPBD_API ID {
  1529. uint64_t _id;
  1530. bool string_assign (std::string);
  1531.  
  1532. - static Glib::Threads::Mutex* counter_lock;
  1533. + static GMutex* counter_lock;
  1534. static uint64_t _counter;
  1535. };
  1536.  
  1537. diff --git a/libs/pbd/pbd/msvc_pbd.h b/libs/pbd/pbd/msvc_pbd.h
  1538. index ed52b55b0a..e448484fb5 100644
  1539. --- a/libs/pbd/pbd/msvc_pbd.h
  1540. +++ b/libs/pbd/pbd/msvc_pbd.h
  1541. @@ -28,8 +28,8 @@
  1542. #ifndef COMPILER_MSVC
  1543. #include <sys/time.h>
  1544. #else
  1545. -#include <ardourext/misc.h>
  1546. -#include <ardourext/sys/time.h>
  1547. +#include <pbd/compat.h>
  1548. +#include <sys/time.h>
  1549. #endif
  1550.  
  1551. #if !defined(PBD_IS_IN_WINDLL)
  1552. diff --git a/libs/pbd/pbd/pool.h b/libs/pbd/pbd/pool.h
  1553. index 0346736b50..224b406682 100644
  1554. --- a/libs/pbd/pbd/pool.h
  1555. +++ b/libs/pbd/pbd/pool.h
  1556. @@ -23,8 +23,8 @@
  1557.  
  1558. #include <string>
  1559. #include <vector>
  1560. -
  1561. -#include <glibmm/threads.h>
  1562. +#include <mutex>
  1563. +#include <thread>
  1564.  
  1565. #include "pbd/libpbd_visibility.h"
  1566. #include "pbd/ringbuffer.h"
  1567. @@ -85,7 +85,7 @@ public:
  1568. virtual void release (void*);
  1569.  
  1570. private:
  1571. - Glib::Threads::Mutex m_lock;
  1572. + std::mutex m_lock;
  1573. };
  1574.  
  1575. class LIBPBD_API MultiAllocSingleReleasePool : public Pool
  1576. @@ -98,7 +98,7 @@ public:
  1577. virtual void release (void*);
  1578.  
  1579. private:
  1580. - Glib::Threads::Mutex m_lock;
  1581. + std::mutex m_lock;
  1582. };
  1583.  
  1584. class LIBPBD_API PerThreadPool;
  1585. @@ -150,10 +150,6 @@ class LIBPBD_API PerThreadPool
  1586. public:
  1587. PerThreadPool ();
  1588.  
  1589. - const Glib::Threads::Private<CrossThreadPool>& key () const
  1590. - {
  1591. - return _key;
  1592. - }
  1593.  
  1594. void create_per_thread_pool (std::string name, unsigned long item_size, unsigned long nitems, PoolDumpCallback cb = NULL);
  1595.  
  1596. @@ -164,13 +160,14 @@ public:
  1597. void add_to_trash (CrossThreadPool*);
  1598.  
  1599. private:
  1600. - Glib::Threads::Private<CrossThreadPool> _key;
  1601. std::string _name;
  1602.  
  1603. /** mutex to protect either changes to the _trash variable, or writes to the RingBuffer */
  1604. - Glib::Threads::Mutex _trash_mutex;
  1605. + std::mutex _trash_mutex;
  1606. PBD::RingBuffer<CrossThreadPool*>* _trash;
  1607. };
  1608.  
  1609. +extern thread_local CrossThreadPool* pbd_tls_pool_ptr;
  1610. +
  1611. } // namespace PBD
  1612.  
  1613. diff --git a/libs/pbd/pbd/pthread_utils.h b/libs/pbd/pbd/pthread_utils.h
  1614. index b864205791..e59bdb403e 100644
  1615. --- a/libs/pbd/pbd/pthread_utils.h
  1616. +++ b/libs/pbd/pbd/pthread_utils.h
  1617. @@ -37,7 +37,7 @@
  1618. #endif /* PTHREAD_MACROS_DEFINED */
  1619.  
  1620. #ifdef COMPILER_MSVC
  1621. -#include <ardourext/pthread.h>
  1622. +#include <pthread.h>
  1623. #else
  1624. #include <pthread.h>
  1625. #endif
  1626. diff --git a/libs/pbd/pbd/scoped_file_descriptor.h b/libs/pbd/pbd/scoped_file_descriptor.h
  1627. index 0d525275aa..0864ee2f6a 100644
  1628. --- a/libs/pbd/pbd/scoped_file_descriptor.h
  1629. +++ b/libs/pbd/pbd/scoped_file_descriptor.h
  1630. @@ -18,7 +18,15 @@
  1631.  
  1632. #pragma once
  1633.  
  1634. +#ifdef COMPILER_MSVC
  1635. +#include <io.h> // _close, intptr_t
  1636. +#include <stdlib.h> // intptr_t
  1637. +inline int close(int fd) { return _close(fd); }
  1638. +#else
  1639. #include <unistd.h>
  1640. +#endif
  1641. +
  1642. +#include <cstddef>
  1643.  
  1644. namespace PBD {
  1645.  
  1646. diff --git a/libs/pbd/pbd/signals.h b/libs/pbd/pbd/signals.h
  1647. index db59407fc0..d2a19f12e4 100644
  1648. --- a/libs/pbd/pbd/signals.h
  1649. +++ b/libs/pbd/pbd/signals.h
  1650. @@ -32,7 +32,8 @@
  1651.  
  1652. #include <atomic>
  1653.  
  1654. -#include <glibmm/threads.h>
  1655. +#include <mutex>
  1656. +#include <thread>
  1657.  
  1658. #include <boost/bind/protect.hpp>
  1659. #include <boost/enable_shared_from_this.hpp>
  1660. @@ -89,7 +90,7 @@ public:
  1661. #endif
  1662.  
  1663. protected:
  1664. - mutable Glib::Threads::Mutex _mutex;
  1665. + mutable std::mutex _mutex;
  1666. std::atomic<bool> _in_dtor;
  1667. #ifdef DEBUG_PBD_SIGNAL_CONNECTIONS
  1668. bool _debug_connection;
  1669. @@ -160,12 +161,12 @@ public:
  1670. operator() (A... a);
  1671.  
  1672. bool empty () const {
  1673. - Glib::Threads::Mutex::Lock lm (_mutex);
  1674. + std::unique_lock<std::mutex> lm (_mutex);
  1675. return _slots.empty ();
  1676. }
  1677.  
  1678. size_t size () const {
  1679. - Glib::Threads::Mutex::Lock lm (_mutex);
  1680. + std::unique_lock<std::mutex> lm (_mutex);
  1681. return _slots.size ();
  1682. }
  1683.  
  1684. @@ -201,7 +202,7 @@ public:
  1685.  
  1686. void disconnect ()
  1687. {
  1688. - Glib::Threads::Mutex::Lock lm (_mutex);
  1689. + std::unique_lock<std::mutex> lm (_mutex);
  1690. SignalBase* signal = _signal.exchange (0, std::memory_order_acq_rel);
  1691. if (signal) {
  1692. /* It is safe to assume that signal has not been destructed.
  1693. @@ -233,7 +234,7 @@ public:
  1694. * be an effective NO-OP since SignalBase::_in_dtor is true,
  1695. * then we can proceed.
  1696. */
  1697. - Glib::Threads::Mutex::Lock lm (_mutex);
  1698. + std::unique_lock<std::mutex> lm (_mutex);
  1699. }
  1700. if (_invalidation_record) {
  1701. _invalidation_record->unref ();
  1702. @@ -241,7 +242,7 @@ public:
  1703. }
  1704.  
  1705. private:
  1706. - Glib::Threads::Mutex _mutex;
  1707. + std::mutex _mutex;
  1708. std::atomic<SignalBase*> _signal;
  1709. PBD::EventLoop::InvalidationRecord* _invalidation_record;
  1710. };
  1711. @@ -292,7 +293,7 @@ class LIBPBD_API ScopedConnectionList
  1712. void add_connection (const UnscopedConnection& c);
  1713. void drop_connections ();
  1714.  
  1715. - std::list<ScopedConnectionList*>::size_type size() const { Glib::Threads::Mutex::Lock lm (_scoped_connection_lock); return _scoped_connection_list.size(); }
  1716. + std::list<ScopedConnectionList*>::size_type size() const { std::unique_lock<std::mutex> lm (_scoped_connection_lock); return _scoped_connection_list.size(); }
  1717.  
  1718. private:
  1719. /* Even though our signals code is thread-safe, this additional list of
  1720. @@ -306,7 +307,7 @@ class LIBPBD_API ScopedConnectionList
  1721. one from another.
  1722. */
  1723.  
  1724. - mutable Glib::Threads::Mutex _scoped_connection_lock;
  1725. + mutable std::mutex _scoped_connection_lock;
  1726.  
  1727. typedef std::list<ScopedConnection*> ConnectionList;
  1728. ConnectionList _scoped_connection_list;
  1729. @@ -325,7 +326,7 @@ template <typename Combiner, typename R, typename... A>
  1730. SignalWithCombiner<Combiner, R(A...)>::~SignalWithCombiner ()
  1731. {
  1732. _in_dtor.store (true, std::memory_order_release);
  1733. - Glib::Threads::Mutex::Lock lm (_mutex);
  1734. + std::unique_lock<std::mutex> lm (_mutex);
  1735. /* Tell our connection objects that we are going away, so they don't try to call us */
  1736. for (typename Slots::const_iterator i = _slots.begin(); i != _slots.end(); ++i) {
  1737. i->first->signal_going_away ();
  1738. @@ -461,7 +462,7 @@ SignalWithCombiner<Combiner, R(A...)>::operator() (A... a)
  1739. */
  1740.  
  1741. {
  1742. - Glib::Threads::Mutex::Lock lm (_mutex);
  1743. + std::unique_lock<std::mutex> lm (_mutex);
  1744. /* copy only the raw pointer, no need for a shared_ptr in this
  1745. * context, we only use the address as a lookup into the _slots
  1746. * container. Note: because of the use of a stack allocator,
  1747. @@ -491,7 +492,7 @@ SignalWithCombiner<Combiner, R(A...)>::operator() (A... a)
  1748. bool still_there = false;
  1749.  
  1750. {
  1751. - Glib::Threads::Mutex::Lock lm (_mutex);
  1752. + std::unique_lock<std::mutex> lm (_mutex);
  1753. typename Slots::const_iterator f = std::find_if (_slots.begin(), _slots.end(), [&](typename Slots::value_type const & elem) { return elem.first.get() == c; });
  1754. if (f != _slots.end()) {
  1755. functor = f->second;
  1756. @@ -562,7 +563,7 @@ SignalWithCombiner<Combiner, R(A...)>::operator() (A... a)
  1757. bool still_there = false;
  1758.  
  1759. {
  1760. - Glib::Threads::Mutex::Lock lm (_mutex);
  1761. + std::unique_lock<std::mutex> lm (_mutex);
  1762. typename Slots::const_iterator f = std::find_if (_slots.begin(), _slots.end(), [&](typename Slots::value_type const & elem) { return elem.first.get() == c; });
  1763.  
  1764. if (f != _slots.end()) {
  1765. @@ -597,7 +598,7 @@ SignalWithCombiner<Combiner, R(A...)>::_connect (PBD::EventLoop::InvalidationRec
  1766. slot_function_type f)
  1767. {
  1768. std::shared_ptr<Connection> c (new Connection (this, ir));
  1769. - Glib::Threads::Mutex::Lock lm (_mutex);
  1770. + std::unique_lock<std::mutex> lm (_mutex);
  1771. _slots[c] = f;
  1772.  
  1773. #ifdef DEBUG_PBD_SIGNAL_CONNECTIONS
  1774. @@ -617,14 +618,14 @@ void
  1775. SignalWithCombiner<Combiner, R(A...)>::disconnect (std::shared_ptr<Connection> c)
  1776. {
  1777. /* ~ScopedConnection can call this concurrently with our d'tor */
  1778. - Glib::Threads::Mutex::Lock lm (_mutex, Glib::Threads::TRY_LOCK);
  1779. - while (!lm.locked()) {
  1780. + std::unique_lock<std::mutex> lm (_mutex, std::try_to_lock);
  1781. + while (!lm.owns_lock()) {
  1782. if (_in_dtor.load (std::memory_order_acquire)) {
  1783. /* d'tor signal_going_away() took care of everything already */
  1784. return;
  1785. }
  1786. /* Spin */
  1787. - lm.try_acquire ();
  1788. + (void)lm.try_lock ();
  1789. }
  1790. _slots.erase (c);
  1791. lm.release ();
  1792. diff --git a/libs/pbd/pbd/stack_allocator.h b/libs/pbd/pbd/stack_allocator.h
  1793. index b5a907711b..da862d00d8 100644
  1794. --- a/libs/pbd/pbd/stack_allocator.h
  1795. +++ b/libs/pbd/pbd/stack_allocator.h
  1796. @@ -105,7 +105,7 @@ public:
  1797.  
  1798. size_type max_size () const throw ()
  1799. {
  1800. - return std::numeric_limits<size_type>::max () / sizeof (T);
  1801. + return (std::numeric_limits<size_type>::max) () / sizeof (T);
  1802. }
  1803.  
  1804. bool operator== (StackAllocator const& a) const
  1805. diff --git a/libs/pbd/pbd/stacktrace.h b/libs/pbd/pbd/stacktrace.h
  1806. index 9ea89f5b30..8563407b2e 100644
  1807. --- a/libs/pbd/pbd/stacktrace.h
  1808. +++ b/libs/pbd/pbd/stacktrace.h
  1809. @@ -27,7 +27,7 @@
  1810.  
  1811. #include <iostream>
  1812. #include <ostream>
  1813. -#include <glibmm/threads.h>
  1814. +#include <glib.h>
  1815. #include <list>
  1816.  
  1817. #ifdef HAVE_EXECINFO
  1818. @@ -57,8 +57,9 @@ public:
  1819. #else
  1820. allocation_backtrace_size = 0;
  1821. #endif
  1822. - Glib::Threads::Mutex::Lock lm (all_mutex);
  1823. + g_mutex_lock (&all_mutex);
  1824. all.push_back (this);
  1825. + g_mutex_unlock (&all_mutex);
  1826. }
  1827.  
  1828. thing_with_backtrace (const thing_with_backtrace<T>& other) {
  1829. @@ -69,16 +70,18 @@ public:
  1830. #else
  1831. allocation_backtrace_size = 0;
  1832. #endif
  1833. - Glib::Threads::Mutex::Lock lm (all_mutex);
  1834. + g_mutex_lock (&all_mutex);
  1835. all.push_back (this);
  1836. + g_mutex_unlock (&all_mutex);
  1837. }
  1838.  
  1839. ~thing_with_backtrace() {
  1840. if (allocation_backtrace_size) {
  1841. delete [] allocation_backtrace;
  1842. }
  1843. - Glib::Threads::Mutex::Lock lm (all_mutex);
  1844. + g_mutex_lock (&all_mutex);
  1845. all.remove (this);
  1846. + g_mutex_unlock (&all_mutex);
  1847. }
  1848.  
  1849. thing_with_backtrace<T>& operator= (const thing_with_backtrace<T>& other) {
  1850. @@ -112,11 +115,11 @@ private:
  1851. void** allocation_backtrace;
  1852. int allocation_backtrace_size;
  1853. static std::list<thing_with_backtrace<T>* > all;
  1854. - static Glib::Threads::Mutex all_mutex;
  1855. + static GMutex all_mutex;
  1856. };
  1857.  
  1858. template<typename T> /*LIBPBD_API*/ std::list<PBD::thing_with_backtrace<T> *> PBD::thing_with_backtrace<T>::all;
  1859. -template<typename T> /*LIBPBD_API*/ Glib::Threads::Mutex PBD::thing_with_backtrace<T>::all_mutex;
  1860. +template<typename T> /*LIBPBD_API*/ GMutex PBD::thing_with_backtrace<T>::all_mutex;
  1861.  
  1862. } // namespace PBD
  1863.  
  1864. diff --git a/libs/pbd/pbd/stateful.h b/libs/pbd/pbd/stateful.h
  1865. index 8bb10b2cbc..74a02c9490 100644
  1866. --- a/libs/pbd/pbd/stateful.h
  1867. +++ b/libs/pbd/pbd/stateful.h
  1868. @@ -27,6 +27,7 @@
  1869. #include <list>
  1870. #include <cassert>
  1871.  
  1872. +#include <glib.h>
  1873. #include "pbd/libpbd_visibility.h"
  1874. #include "pbd/id.h"
  1875. #include "pbd/xml++.h"
  1876. @@ -123,7 +124,7 @@ class LIBPBD_API Stateful {
  1877. XMLNode *_extra_xml;
  1878. XMLNode *_instant_xml;
  1879. PBD::PropertyChange _pending_changed;
  1880. - Glib::Threads::Mutex _lock;
  1881. + GMutex _lock;
  1882.  
  1883. std::string _xml_node_name; ///< name of node to use for this object in XML
  1884. OwnedPropertyList* _properties;
  1885. @@ -138,7 +139,7 @@ class LIBPBD_API Stateful {
  1886.  
  1887. private:
  1888. friend struct ForceIDRegeneration;
  1889. - static Glib::Threads::Private<bool> _regenerate_xml_or_string_ids;
  1890. + static GPrivate* _regenerate_xml_or_string_ids;
  1891.  
  1892. PBD::ID _id;
  1893. std::atomic<int> _stateful_frozen;
  1894. diff --git a/libs/pbd/pbd/timer.h b/libs/pbd/pbd/timer.h
  1895. index 6c95da2537..dccf5676b2 100644
  1896. --- a/libs/pbd/pbd/timer.h
  1897. +++ b/libs/pbd/pbd/timer.h
  1898. @@ -88,7 +88,7 @@ public:
  1899. StandardTimer (unsigned int interval,
  1900. const Glib::RefPtr<Glib::MainContext>& main_context = Glib::MainContext::get_default());
  1901.  
  1902. - sigc::connection connect (const sigc::slot<void>& slot);
  1903. + sigc::connection connect (const sigc::slot<void()>& slot);
  1904.  
  1905. virtual unsigned int connection_count () const
  1906. { return m_signal.size (); }
  1907. @@ -97,7 +97,7 @@ protected:
  1908.  
  1909. virtual bool on_elapsed ();
  1910.  
  1911. - sigc::signal<void> m_signal;
  1912. + sigc::signal<void()> m_signal;
  1913.  
  1914. };
  1915.  
  1916. @@ -109,7 +109,7 @@ public:
  1917. const Glib::RefPtr<Glib::MainContext>& main_context = Glib::MainContext::get_default());
  1918.  
  1919.  
  1920. - sigc::connection connect (const sigc::slot<void, bool>& slot);
  1921. + sigc::connection connect (const sigc::slot<void(bool)>& slot);
  1922.  
  1923. virtual unsigned int connection_count () const
  1924. { return m_blink_signal.size (); }
  1925. @@ -118,7 +118,7 @@ protected:
  1926.  
  1927. virtual bool on_elapsed ();
  1928.  
  1929. - sigc::signal<void, bool> m_blink_signal;
  1930. + sigc::signal<void(bool)> m_blink_signal;
  1931.  
  1932. };
  1933.  
  1934. diff --git a/libs/pbd/pbd/undo.h b/libs/pbd/pbd/undo.h
  1935. index 5d93d451ac..158c9087ca 100644
  1936. --- a/libs/pbd/pbd/undo.h
  1937. +++ b/libs/pbd/pbd/undo.h
  1938. @@ -25,14 +25,14 @@
  1939. #include <list>
  1940. #include <map>
  1941. #include <string>
  1942. -
  1943. +#include <ctime>
  1944. #include <sigc++/bind.h>
  1945. #include <sigc++/slot.h>
  1946.  
  1947. -#ifndef COMPILER_MSVC
  1948. -#include <sys/time.h>
  1949. +#ifdef COMPILER_MSVC
  1950. +#include <winsock2.h>
  1951. #else
  1952. -#include <ardourext/misc.h>
  1953. +#include <sys/time.h>
  1954. #endif
  1955.  
  1956. #include "pbd/command.h"
  1957. @@ -67,19 +67,19 @@ public:
  1958.  
  1959. XMLNode& get_state () const;
  1960.  
  1961. - void set_timestamp (struct timeval& t)
  1962. + void set_timestamp (::timeval& t)
  1963. {
  1964. _timestamp = t;
  1965. }
  1966.  
  1967. - const struct timeval& timestamp () const
  1968. + const ::timeval& timestamp () const
  1969. {
  1970. return _timestamp;
  1971. }
  1972.  
  1973. private:
  1974. std::list<PBD::Command*> actions;
  1975. - struct timeval _timestamp;
  1976. + ::timeval _timestamp;
  1977. bool _clearing;
  1978.  
  1979. void about_to_explicitly_delete ();
  1980. diff --git a/libs/pbd/pbd/windows_special_dirs.h b/libs/pbd/pbd/windows_special_dirs.h
  1981. index 179fef1014..c9b267efe9 100644
  1982. --- a/libs/pbd/pbd/windows_special_dirs.h
  1983. +++ b/libs/pbd/pbd/windows_special_dirs.h
  1984. @@ -21,7 +21,11 @@
  1985.  
  1986. #pragma once
  1987.  
  1988. +#define WIN32_LEAN_AND_MEAN
  1989. +#define NOMINMAX
  1990. +
  1991. #include <windows.h>
  1992. +
  1993. #include <string>
  1994.  
  1995. #include "pbd/libpbd_visibility.h"
  1996. diff --git a/libs/pbd/pool.cc b/libs/pbd/pool.cc
  1997. index 83c8d29ac7..3a5afa8e5c 100644
  1998. --- a/libs/pbd/pool.cc
  1999. +++ b/libs/pbd/pool.cc
  2000. @@ -35,6 +35,8 @@
  2001. using namespace std;
  2002. using namespace PBD;
  2003.  
  2004. +thread_local CrossThreadPool* PBD::pbd_tls_pool_ptr = nullptr;
  2005. +
  2006. Pool::Pool (string n, unsigned long item_size, unsigned long nitems, PoolDumpCallback cb)
  2007. : free_list (nitems)
  2008. , _name (n)
  2009. @@ -132,7 +134,7 @@ SingleAllocMultiReleasePool::~SingleAllocMultiReleasePool ()
  2010. void*
  2011. MultiAllocSingleReleasePool::alloc ()
  2012. {
  2013. - Glib::Threads::Mutex::Lock guard (m_lock);
  2014. + std::lock_guard<std::mutex> guard (m_lock);
  2015. return Pool::alloc ();
  2016. }
  2017.  
  2018. @@ -151,7 +153,7 @@ SingleAllocMultiReleasePool::alloc ()
  2019. void
  2020. SingleAllocMultiReleasePool::release (void* ptr)
  2021. {
  2022. - Glib::Threads::Mutex::Lock guard (m_lock);
  2023. + std::lock_guard<std::mutex> guard (m_lock);
  2024. Pool::release (ptr);
  2025. }
  2026.  
  2027. @@ -182,8 +184,7 @@ free_per_thread_pool (void* ptr)
  2028. }
  2029.  
  2030. PerThreadPool::PerThreadPool ()
  2031. - : _key (free_per_thread_pool)
  2032. - , _trash (0)
  2033. + : _trash (nullptr)
  2034. {
  2035. }
  2036.  
  2037. @@ -195,7 +196,7 @@ PerThreadPool::PerThreadPool ()
  2038. void
  2039. PerThreadPool::create_per_thread_pool (string n, unsigned long isize, unsigned long nitems, PoolDumpCallback cb)
  2040. {
  2041. - _key.set (new CrossThreadPool (n, isize, nitems, this, cb));
  2042. + pbd_tls_pool_ptr = new CrossThreadPool (n, isize, nitems, this, cb);
  2043. }
  2044.  
  2045. /** @return True if CrossThreadPool for the current thread exists,
  2046. @@ -204,7 +205,7 @@ PerThreadPool::create_per_thread_pool (string n, unsigned long isize, unsigned l
  2047. bool
  2048. PerThreadPool::has_per_thread_pool ()
  2049. {
  2050. - CrossThreadPool* p = _key.get ();
  2051. + CrossThreadPool* p = pbd_tls_pool_ptr;
  2052. if (p) {
  2053. return true;
  2054. }
  2055. @@ -217,7 +218,7 @@ PerThreadPool::has_per_thread_pool ()
  2056. CrossThreadPool*
  2057. PerThreadPool::per_thread_pool (bool must_exist)
  2058. {
  2059. - CrossThreadPool* p = _key.get ();
  2060. + CrossThreadPool* p = pbd_tls_pool_ptr;
  2061. if (!p && must_exist) {
  2062. fatal << "programming error: no per-thread pool \"" << _name << "\" for thread " << pthread_name () << endmsg;
  2063. abort (); /*NOTREACHED*/
  2064. @@ -228,7 +229,7 @@ PerThreadPool::per_thread_pool (bool must_exist)
  2065. void
  2066. PerThreadPool::set_trash (RingBuffer<CrossThreadPool*>* t)
  2067. {
  2068. - Glib::Threads::Mutex::Lock lm (_trash_mutex);
  2069. + std::lock_guard<std::mutex> lm (_trash_mutex);
  2070. _trash = t;
  2071. }
  2072.  
  2073. @@ -236,7 +237,7 @@ PerThreadPool::set_trash (RingBuffer<CrossThreadPool*>* t)
  2074. void
  2075. PerThreadPool::add_to_trash (CrossThreadPool* p)
  2076. {
  2077. - Glib::Threads::Mutex::Lock lm (_trash_mutex);
  2078. + std::lock_guard<std::mutex> lm (_trash_mutex);
  2079.  
  2080. if (!_trash) {
  2081. warning << "Pool " << p->name () << " has no trash collector; a memory leak has therefore occurred" << endmsg;
  2082. diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc
  2083. index c3d54afc80..40cec75b47 100644
  2084. --- a/libs/pbd/pthread_utils.cc
  2085. +++ b/libs/pbd/pthread_utils.cc
  2086. @@ -37,28 +37,41 @@
  2087. #include "pbd/failed_constructor.h"
  2088. #include "pbd/pthread_utils.h"
  2089.  
  2090. -#ifdef COMPILER_MSVC
  2091. -DECLARE_DEFAULT_COMPARISONS (pthread_t) // Needed for 'DECLARE_DEFAULT_COMPARISONS'. Objects in an STL container can be
  2092. - // searched and sorted. Thus, when instantiating the container, MSVC complains
  2093. - // if the type of object being contained has no appropriate comparison operators
  2094. - // defined (specifically, if operators '<' and '==' are undefined). This seems
  2095. - // to be the case with ptw32 'pthread_t' which is a simple struct.
  2096. -
  2097. -#define pthread_gethandle pthread_getw32threadhandle_np
  2098. -#endif
  2099. -
  2100. #ifdef __APPLE__
  2101. #include <mach/mach_time.h>
  2102. #include <mach/thread_act.h>
  2103. #include <mach/thread_policy.h>
  2104. #endif
  2105.  
  2106. +#ifdef COMPILER_MSVC
  2107. +/* MSVC needs < and == for pthread_t because it is an opaque struct. */
  2108. +namespace std {
  2109. + template<>
  2110. + struct less<pthread_t> {
  2111. + bool operator() (const pthread_t& a, const pthread_t& b) const {
  2112. + return a.p < b.p; // ptw32 layout: first member is the Win32 HANDLE
  2113. + }
  2114. + };
  2115. +
  2116. + inline bool operator== (const pthread_t& a, const pthread_t& b) {
  2117. + return a.p == b.p;
  2118. + }
  2119. + inline bool operator!= (const pthread_t& a, const pthread_t& b) {
  2120. + return !(a == b);
  2121. + }
  2122. +}
  2123. +#define pthread_gethandle pthread_getw32threadhandle_np
  2124. +#endif
  2125. +
  2126. +
  2127. +
  2128. +
  2129. using namespace std;
  2130.  
  2131. typedef std::map<pthread_t, std::string> ThreadMap;
  2132. static ThreadMap all_threads;
  2133. static pthread_mutex_t thread_map_lock = PTHREAD_MUTEX_INITIALIZER;
  2134. -static Glib::Threads::Private<char> thread_name (free);
  2135. +static thread_local std::string thread_name;
  2136. static int base_priority_relative_to_max = -20;
  2137.  
  2138. #ifdef PLATFORM_WINDOWS
  2139. @@ -234,8 +247,7 @@ pthread_create_and_store (string name, pthread_t* thread, void* (*start_routine)
  2140. void
  2141. pthread_set_name (const char* str)
  2142. {
  2143. - /* copy string and delete it when exiting */
  2144. - thread_name.set (strdup (str)); // leaks
  2145. + thread_name = str;
  2146.  
  2147. #if !defined PTW32_VERSION && defined _GNU_SOURCE
  2148. /* set public thread name, up to 16 chars */
  2149. @@ -249,10 +261,8 @@ pthread_set_name (const char* str)
  2150. const char*
  2151. pthread_name ()
  2152. {
  2153. - const char* str = thread_name.get ();
  2154. -
  2155. - if (str) {
  2156. - return str;
  2157. + if (!thread_name.empty()) {
  2158. + return thread_name.c_str();
  2159. }
  2160. return "unknown";
  2161. }
  2162. @@ -443,7 +453,7 @@ pbd_set_thread_priority (pthread_t thread, int policy, int priority)
  2163. DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Change '%1' to policy = %2 priority = %3\n", pthread_name(), policy, param.sched_priority));
  2164.  
  2165. #ifdef PLATFORM_WINDOWS
  2166. - if (is_pthread_active (thread) && param.sched_priority >= 12) {
  2167. + if (param.sched_priority >= 12) {
  2168. if (set_win_set_realtime_policy (thread, param.sched_priority)) {
  2169. return 0;
  2170. }
  2171. @@ -611,5 +621,29 @@ PBD::Thread::join ()
  2172. bool
  2173. PBD::Thread::caller_is_self () const
  2174. {
  2175. - return pthread_equal (_t, pthread_self ()) != 0;
  2176. + return pthread_equal (_t, pthread_self ());
  2177. +}
  2178. +
  2179. +#ifdef COMPILER_MSVC
  2180. +extern "C" int
  2181. +pthread_setname_np (pthread_t thread, const char* name)
  2182. +{
  2183. + char buf[16];
  2184. + strncpy (buf, name, 15);
  2185. + buf[15] = 0;
  2186. +
  2187. + #pragma pack(push,8)
  2188. + struct { DWORD type; LPCSTR szName; DWORD threadId; DWORD flags; } info = {
  2189. + 0x1000, buf, static_cast<DWORD>(pthread_getw32threadid_np(thread)), 0
  2190. + };
  2191. + #pragma pack(pop)
  2192. +
  2193. + __try {
  2194. + RaiseException (0x406D1384, 0, sizeof(info)/sizeof(ULONG_PTR),
  2195. + reinterpret_cast<ULONG_PTR*>(&info));
  2196. + } __except(EXCEPTION_EXECUTE_HANDLER) {
  2197. + /* name not supported on this OS version – benign */
  2198. + }
  2199. + return 0;
  2200. }
  2201. +#endif
  2202. \ No newline at end of file
  2203. diff --git a/libs/pbd/signals.cc b/libs/pbd/signals.cc
  2204. index 3c9d14dac5..e75ab9274c 100644
  2205. --- a/libs/pbd/signals.cc
  2206. +++ b/libs/pbd/signals.cc
  2207. @@ -18,6 +18,7 @@
  2208. */
  2209.  
  2210. #include "pbd/signals.h"
  2211. +#include <glib.h>
  2212. #include "pbd/demangle.h"
  2213.  
  2214. using namespace PBD;
  2215. @@ -34,17 +35,17 @@ ScopedConnectionList::~ScopedConnectionList()
  2216. void
  2217. ScopedConnectionList::add_connection (const UnscopedConnection& c)
  2218. {
  2219. - Glib::Threads::Mutex::Lock lm (_scoped_connection_lock);
  2220. + std::lock_guard<std::mutex> lock(_scoped_connection_lock);
  2221. _scoped_connection_list.push_back (new ScopedConnection (c));
  2222. }
  2223.  
  2224. void
  2225. ScopedConnectionList::drop_connections ()
  2226. {
  2227. - Glib::Threads::Mutex::Lock lm (_scoped_connection_lock);
  2228. + std::lock_guard<std::mutex> lock(_scoped_connection_lock);
  2229.  
  2230. - for (ConnectionList::iterator i = _scoped_connection_list.begin(); i != _scoped_connection_list.end(); ++i) {
  2231. - delete *i;
  2232. + for (auto* conn : _scoped_connection_list) {
  2233. + delete conn;
  2234. }
  2235.  
  2236. _scoped_connection_list.clear ();
  2237. diff --git a/libs/pbd/stateful.cc b/libs/pbd/stateful.cc
  2238. index 9879c7ee2e..3406aee143 100644
  2239. --- a/libs/pbd/stateful.cc
  2240. +++ b/libs/pbd/stateful.cc
  2241. @@ -42,7 +42,7 @@ namespace PBD {
  2242. int Stateful::current_state_version = 0;
  2243. int Stateful::loading_state_version = 0;
  2244.  
  2245. -Glib::Threads::Private<bool> Stateful::_regenerate_xml_or_string_ids;
  2246. +GPrivate* Stateful::_regenerate_xml_or_string_ids = nullptr;
  2247.  
  2248. Stateful::Stateful ()
  2249. : _extra_xml (nullptr)
  2250. @@ -110,7 +110,7 @@ Stateful::save_extra_xml (const XMLNode& node)
  2251. void
  2252. Stateful::add_instant_xml (XMLNode& node, const std::string& directory_path)
  2253. {
  2254. - if (!Glib::file_test (directory_path, Glib::FILE_TEST_IS_DIR)) {
  2255. + if (!g_file_test (directory_path.c_str(), G_FILE_TEST_IS_DIR)) {
  2256. if (g_mkdir_with_parents (directory_path.c_str(), 0755) != 0) {
  2257. error << string_compose(_("Error: could not create directory %1"), directory_path) << endmsg;
  2258. return;
  2259. @@ -153,7 +153,7 @@ Stateful::instant_xml (const string& str, const std::string& directory_path)
  2260. if (_instant_xml == nullptr) {
  2261. std::string instant_xml_path = Glib::build_filename (directory_path, "instant.xml");
  2262.  
  2263. - if (Glib::file_test (instant_xml_path, Glib::FILE_TEST_EXISTS)) {
  2264. + if (g_file_test (instant_xml_path.c_str(), G_FILE_TEST_EXISTS)) {
  2265. XMLTree tree;
  2266. if (tree.read(instant_xml_path)) {
  2267. _instant_xml = new XMLNode(*(tree.root()));
  2268. @@ -287,13 +287,14 @@ Stateful::send_change (const PropertyChange& what_changed)
  2269. }
  2270.  
  2271. {
  2272. - Glib::Threads::Mutex::Lock lm (_lock);
  2273. + g_mutex_lock (&_lock);
  2274. if (property_changes_suspended ()) {
  2275. _pending_changed.add (what_changed);
  2276. + g_mutex_unlock (&_lock);
  2277. return;
  2278. }
  2279. }
  2280. -
  2281. + g_mutex_unlock (&_lock);
  2282. PropertyChanged (what_changed);
  2283. }
  2284.  
  2285. @@ -309,9 +310,10 @@ Stateful::resume_property_changes ()
  2286. PropertyChange what_changed;
  2287.  
  2288. {
  2289. - Glib::Threads::Mutex::Lock lm (_lock);
  2290. + g_mutex_lock (&_lock);
  2291.  
  2292. if (property_changes_suspended() && PBD::atomic_dec_and_test (_stateful_frozen) == FALSE) {
  2293. + g_mutex_unlock (&_lock);
  2294. return;
  2295. }
  2296.  
  2297. @@ -319,6 +321,7 @@ Stateful::resume_property_changes ()
  2298. what_changed = _pending_changed;
  2299. _pending_changed.clear ();
  2300. }
  2301. + g_mutex_unlock (&_lock);
  2302. }
  2303.  
  2304. mid_thaw (what_changed);
  2305. @@ -385,7 +388,7 @@ Stateful::clear_owned_changes ()
  2306. bool
  2307. Stateful::set_id (const XMLNode& node)
  2308. {
  2309. - bool* regen = _regenerate_xml_or_string_ids.get();
  2310. + bool* regen = (bool*) g_private_get (_regenerate_xml_or_string_ids);
  2311.  
  2312. if (regen && *regen) {
  2313. reset_id ();
  2314. @@ -405,22 +408,22 @@ Stateful::reset_id ()
  2315. _id = ID ();
  2316. }
  2317.  
  2318. -void
  2319. -Stateful::set_id (const string& str)
  2320. -{
  2321. - bool* regen = _regenerate_xml_or_string_ids.get();
  2322. + void
  2323. + Stateful::set_id (const string& str)
  2324. + {
  2325. + bool* regen = (bool*) g_private_get (_regenerate_xml_or_string_ids);
  2326.  
  2327. - if (regen && *regen) {
  2328. - reset_id ();
  2329. - } else {
  2330. - _id = str;
  2331. + if (regen && *regen) {
  2332. + reset_id ();
  2333. + } else {
  2334. + _id = str;
  2335. + }
  2336. }
  2337. -}
  2338.  
  2339. bool
  2340. Stateful::regenerate_xml_or_string_ids () const
  2341. {
  2342. - bool* regen = _regenerate_xml_or_string_ids.get();
  2343. + bool* regen = (bool*) g_private_get (_regenerate_xml_or_string_ids);
  2344. if (regen && *regen) {
  2345. return true;
  2346. } else {
  2347. @@ -431,8 +434,9 @@ Stateful::regenerate_xml_or_string_ids () const
  2348. void
  2349. Stateful::set_regenerate_xml_and_string_ids_in_this_thread (bool yn)
  2350. {
  2351. - bool* val = new bool (yn);
  2352. - _regenerate_xml_or_string_ids.set (val);
  2353. + if (!_regenerate_xml_or_string_ids)
  2354. + _regenerate_xml_or_string_ids = g_private_new (g_free);
  2355. + g_private_set (_regenerate_xml_or_string_ids, g_memdup (&yn, sizeof (bool)));
  2356. }
  2357.  
  2358. } // namespace PBD
  2359. diff --git a/libs/pbd/system_exec.cc b/libs/pbd/system_exec.cc
  2360. index 8570dfa598..b520993224 100644
  2361. --- a/libs/pbd/system_exec.cc
  2362. +++ b/libs/pbd/system_exec.cc
  2363. @@ -22,7 +22,9 @@
  2364. #include <stdlib.h>
  2365. #include <string.h>
  2366. #include <errno.h>
  2367. +#ifndef COMPILER_MSVC
  2368. #include <unistd.h>
  2369. +#endif
  2370. #include <algorithm>
  2371.  
  2372. #include <assert.h>
  2373. diff --git a/libs/pbd/timer.cc b/libs/pbd/timer.cc
  2374. index 0bbfeb96ea..5f8affdb8a 100644
  2375. --- a/libs/pbd/timer.cc
  2376. +++ b/libs/pbd/timer.cc
  2377. @@ -106,7 +106,7 @@ StandardTimer::StandardTimer(unsigned int interval,
  2378. { }
  2379.  
  2380. sigc::connection
  2381. -StandardTimer::connect(const sigc::slot<void>& slot)
  2382. +StandardTimer::connect(const sigc::slot<void()>& slot)
  2383. {
  2384. if(m_signal.size() == 0) { start(); }
  2385.  
  2386. @@ -134,7 +134,7 @@ BlinkTimer::BlinkTimer(unsigned int interval,
  2387. { }
  2388.  
  2389. sigc::connection
  2390. -BlinkTimer::connect(const sigc::slot<void, bool>& slot)
  2391. +BlinkTimer::connect(const sigc::slot<void(bool)>& slot)
  2392. {
  2393. if(m_blink_signal.size() == 0) { start(); }
  2394.  
  2395. diff --git a/libs/pbd/undo.cc b/libs/pbd/undo.cc
  2396. index 7c12abf1a4..67ac163306 100644
  2397. --- a/libs/pbd/undo.cc
  2398. +++ b/libs/pbd/undo.cc
  2399. @@ -35,7 +35,13 @@ using namespace PBD;
  2400. UndoTransaction::UndoTransaction ()
  2401. : _clearing (false)
  2402. {
  2403. +#ifdef COMPILER_MSVC
  2404. + gint64 now = g_get_real_time ();
  2405. + _timestamp.tv_sec = now / G_USEC_PER_SEC;
  2406. + _timestamp.tv_usec = now % G_USEC_PER_SEC;
  2407. +#else
  2408. gettimeofday (&_timestamp, 0);
  2409. +#endif
  2410. }
  2411.  
  2412. UndoTransaction::UndoTransaction (const UndoTransaction& rhs)
  2413. diff --git a/libs/pbd/windows_special_dirs.cc b/libs/pbd/windows_special_dirs.cc
  2414. index 713677675f..cb59217dfd 100644
  2415. --- a/libs/pbd/windows_special_dirs.cc
  2416. +++ b/libs/pbd/windows_special_dirs.cc
  2417. @@ -17,21 +17,34 @@
  2418. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  2419. */
  2420.  
  2421. +#include "pbd/windows_special_dirs.h"
  2422. +
  2423. #include <shlobj.h>
  2424. #include <winreg.h>
  2425. -#include <glibmm.h>
  2426. +#include <limits.h>
  2427. +#include <glib.h>
  2428. +#include <glibmm/convert.h>
  2429.  
  2430. -#include "pbd/windows_special_dirs.h"
  2431. +#ifdef _WIN32
  2432. +#undef read
  2433. +#undef write
  2434. +#undef close
  2435. +#undef flush
  2436. +#undef seek
  2437. +#endif
  2438. +
  2439. +#if !defined(PATH_MAX) && defined(MAX_PATH)
  2440. +#define PATH_MAX MAX_PATH
  2441. +#endif
  2442.  
  2443. std::string
  2444. PBD::get_win_special_folder_path (int csidl)
  2445. {
  2446. - wchar_t path[PATH_MAX+1];
  2447. - HRESULT hr;
  2448. - LPITEMIDLIST pidl = 0;
  2449. - char *utf8_folder_path = 0;
  2450. + wchar_t path[PATH_MAX+1]{};
  2451. + LPITEMIDLIST pidl = nullptr ;
  2452. + char *utf8_folder_path = nullptr;
  2453.  
  2454. - if (S_OK == (hr = SHGetSpecialFolderLocation (0, csidl, &pidl))) {
  2455. + if (S_OK == SHGetSpecialFolderLocation (nullptr, csidl, &pidl)) {
  2456.  
  2457. if (SHGetPathFromIDListW (pidl, path)) {
  2458. utf8_folder_path = g_utf16_to_utf8 ((const gunichar2*)path, -1, 0, 0, 0);
  2459. @@ -44,7 +57,7 @@ PBD::get_win_special_folder_path (int csidl)
  2460. g_free (utf8_folder_path);
  2461. return folder_path;
  2462. }
  2463. - return std::string();
  2464. + return {};
  2465. }
  2466.  
  2467. bool
  2468. @@ -52,7 +65,7 @@ PBD::windows_query_registry (const char *regkey, const char *regval, std::string
  2469. {
  2470. HKEY key;
  2471. DWORD size = PATH_MAX;
  2472. - char tmp[PATH_MAX+1];
  2473. + char tmp[PATH_MAX+1]{};
  2474.  
  2475. if (ERROR_SUCCESS == RegOpenKeyExA (root, regkey, 0, KEY_READ, &key)) {
  2476. if (ERROR_SUCCESS == RegQueryValueExA (key, regval, 0, NULL, reinterpret_cast<LPBYTE>(tmp), &size)) {
  2477. diff --git a/libs/pbd/wscript b/libs/pbd/wscript
  2478. index a2c429b63c..e6fdb89b64 100644
  2479. --- a/libs/pbd/wscript
  2480. +++ b/libs/pbd/wscript
  2481. @@ -99,6 +99,7 @@ def options(opt):
  2482. def configure(conf):
  2483. autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
  2484. autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0')
  2485. + autowaf.check_pkg(conf, 'pthreadVC3', uselib_store='PTHREADVC3', mandatory=True)
  2486. autowaf.check_pkg(conf, 'libcurl', uselib_store='CURL', atleast_version='7.0.0', mandatory=True)
  2487. autowaf.check_pkg(conf, 'libarchive', uselib_store='ARCHIVE', atleast_version='3.0.0', mandatory=True)
  2488. autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.32.0', mandatory=True)
  2489. @@ -179,10 +180,14 @@ def build(bld):
  2490. obj.defines += [ 'USE_X86_64_ASM' ]
  2491. if bld.env['build_target'] == 'mingw' or bld.env['build_target'] == 'msvc':
  2492. obj.defines += [ 'NO_POSIX_MEMALIGN' ]
  2493. + if bld.env['build_target'] == 'msvc':
  2494. + obj.lib = ['advapi32', 'shell32', 'ws2_32', 'dbghelp', 'user32', 'ole32', 'winmm']
  2495. + obj.uselib += ' PTHREADVC3'
  2496. + else:
  2497. + obj.uselib += ' OLE32 ADVAPI32 SHELL32 WINMM USER32 WSOCK32 WS2_32 DBGHELP GDI32 OLEAUT32 UUID COMCTL32 IMM32 WININET PTHREADVC3'
  2498. obj.source += [ 'windows_special_dirs.cc' ]
  2499. obj.source += [ 'windows_timer_utils.cc' ]
  2500. obj.source += [ 'windows_mmcss.cc' ]
  2501. - obj.uselib += ' OLE'
  2502.  
  2503. if bld.env['BUILD_TESTS'] and bld.is_defined('HAVE_CPPUNIT'):
  2504. # Unit tests
  2505. diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc
  2506. index 08e88716d1..88fa6094b1 100644
  2507. --- a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc
  2508. +++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc
  2509. @@ -28,7 +28,7 @@
  2510.  
  2511. #ifdef COMPILER_MSVC
  2512. #include <io.h> // Microsoft's nearest equivalent to <unistd.h>
  2513. -#include <ardourext/misc.h>
  2514. +#include <pbd/compat.h>
  2515. #else
  2516. #include <regex.h>
  2517. #endif
  2518. diff --git a/libs/temporal/temporal/tempo.h b/libs/temporal/temporal/tempo.h
  2519. index 738dda4392..fb85126781 100644
  2520. --- a/libs/temporal/temporal/tempo.h
  2521. +++ b/libs/temporal/temporal/tempo.h
  2522. @@ -27,8 +27,6 @@
  2523.  
  2524. #include <boost/intrusive/list.hpp>
  2525.  
  2526. -#include <glibmm/threads.h>
  2527. -
  2528. #include "pbd/command.h"
  2529. #include "pbd/enum_convert.h"
  2530. #include "pbd/integer_division.h"
  2531. diff --git a/libs/tk/ydk-pixbuf/gdk-pixbuf-io.c b/libs/tk/ydk-pixbuf/gdk-pixbuf-io.c
  2532. index 7c50b87460..c1369191ec 100644
  2533. --- a/libs/tk/ydk-pixbuf/gdk-pixbuf-io.c
  2534. +++ b/libs/tk/ydk-pixbuf/gdk-pixbuf-io.c
  2535. @@ -26,9 +26,6 @@
  2536. #include <stdio.h>
  2537. #include <string.h>
  2538. #include <errno.h>
  2539. -#ifdef HAVE_UNISTD_H
  2540. -#include <unistd.h>
  2541. -#endif
  2542.  
  2543. #include <glib.h>
  2544. #include <gio/gio.h>
  2545. diff --git a/libs/tk/ydk-pixbuf/io-xbm.c b/libs/tk/ydk-pixbuf/io-xbm.c
  2546. index 1856adab51..b101fdf2cc 100644
  2547. --- a/libs/tk/ydk-pixbuf/io-xbm.c
  2548. +++ b/libs/tk/ydk-pixbuf/io-xbm.c
  2549. @@ -30,9 +30,6 @@
  2550. #include "config.h"
  2551. #include <stdlib.h>
  2552. #include <string.h>
  2553. -#ifdef HAVE_UNISTD_H
  2554. -#include <unistd.h>
  2555. -#endif
  2556. #include <stdio.h>
  2557. #include <errno.h>
  2558. #include "gdk-pixbuf-private.h"
  2559. diff --git a/libs/tk/ydk-pixbuf/io-xpm.c b/libs/tk/ydk-pixbuf/io-xpm.c
  2560. index 27add284ca..90bd351fd9 100644
  2561. --- a/libs/tk/ydk-pixbuf/io-xpm.c
  2562. +++ b/libs/tk/ydk-pixbuf/io-xpm.c
  2563. @@ -26,9 +26,6 @@
  2564. #include <stdlib.h>
  2565. #include <string.h>
  2566. #include <glib.h>
  2567. -#ifdef HAVE_UNISTD_H
  2568. -#include <unistd.h> /* for unlink */
  2569. -#endif
  2570. #include <errno.h>
  2571. #include "gdk-pixbuf-private.h"
  2572. #include <glib/gstdio.h>
  2573. diff --git a/libs/tk/ydk/win32/bdfcursor.c b/libs/tk/ydk/win32/bdfcursor.c
  2574. index 599f365747..ae56893c29 100644
  2575. --- a/libs/tk/ydk/win32/bdfcursor.c
  2576. +++ b/libs/tk/ydk/win32/bdfcursor.c
  2577. @@ -24,6 +24,10 @@
  2578. #include <ctype.h>
  2579. #include <stdlib.h>
  2580.  
  2581. +#ifdef _MSC_VER
  2582. +#define strncasecmp _strnicmp
  2583. +#endif
  2584. +
  2585. #include <glib.h>
  2586.  
  2587. typedef struct {
  2588. diff --git a/libs/tk/ydk/wscript b/libs/tk/ydk/wscript
  2589. index ecff3c21cf..429090dfe0 100644
  2590. --- a/libs/tk/ydk/wscript
  2591. +++ b/libs/tk/ydk/wscript
  2592. @@ -188,13 +188,18 @@ def build(bld):
  2593. obj.export_includes += ['quartz']
  2594. elif bld.env['build_target'] == 'mingw' or bld.env['build_target'] == 'msvc':
  2595. obj.source = libydk_sources + libydk_win32_sources
  2596. - obj.cflags += ['-mms-bitfields', '-Wl,--export-all-symbols']
  2597. obj.uselib += ' GIO-WINDOWS'
  2598. obj.defines += [ 'INSIDE_GDK_WIN32', 'DLL_EXPORT', 'PIC' ]
  2599. obj.includes += ['win32', 'win32/ydk']
  2600. obj.export_includes += ['win32']
  2601. - obj.linkflags = ['-Wl,--export-all-symbols']
  2602. - obj.ldflags = '-limm32 -lole32 -lgdi32 -lcomdlg32 -lwinspool -lcomctl32 -luuid'
  2603. + if bld.env['build_target'] == 'mingw':
  2604. + obj.cflags += ['-mms-bitfields']
  2605. + obj.linkflags = ['-Wl,--export-all-symbols']
  2606. + obj.ldflags = '-limm32 -lole32 -lgdi32 -lcomdlg32 -lwinspool -lcomctl32 -luuid'
  2607. + else:
  2608. + obj.lib = ['imm32', 'ole32', 'gdi32', 'comdlg32', 'winspool', 'comctl32', 'uuid', 'user32', 'shell32', 'advapi32']
  2609. +
  2610. +
  2611. else:
  2612. obj.source = libydk_sources + libydk_x11_sources
  2613. obj.uselib += ' GIO-UNIX X11 XEXT XINERAMA RANDR DL'
  2614. diff --git a/libs/tk/ydkmm/wscript b/libs/tk/ydkmm/wscript
  2615. index b1dc925890..f60f7c348a 100644
  2616. --- a/libs/tk/ydkmm/wscript
  2617. +++ b/libs/tk/ydkmm/wscript
  2618. @@ -45,8 +45,8 @@ def options(opt):
  2619.  
  2620. def configure(conf):
  2621. autowaf.check_pkg(conf, 'giomm-2.4', uselib_store='GIOMM', atleast_version='2.2', mandatory=True)
  2622. - autowaf.check_pkg(conf, 'cairomm-1.0', uselib_store='CAIROMM', atleast_version='1.8.4', mandatory=True)
  2623. - autowaf.check_pkg(conf, 'pangomm-1.4', uselib_store='PANGOMM', atleast_version='1.4', mandatory=True)
  2624. + autowaf.check_pkg(conf, 'cairomm-1.16', uselib_store='CAIROMM', atleast_version='1.8.4', mandatory=True)
  2625. + autowaf.check_pkg(conf, 'pangomm-2.48', uselib_store='PANGOMM', atleast_version='1.4', mandatory=True)
  2626. autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.32.0', mandatory=True)
  2627. autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0', mandatory=True)
  2628.  
  2629. diff --git a/libs/tk/ztkmm/wscript b/libs/tk/ztkmm/wscript
  2630. index dcee2d2029..aebb486847 100644
  2631. --- a/libs/tk/ztkmm/wscript
  2632. +++ b/libs/tk/ztkmm/wscript
  2633. @@ -38,7 +38,7 @@ def options(opt):
  2634.  
  2635. def configure(conf):
  2636. autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.32.0', mandatory=True)
  2637. - autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0', mandatory=True)
  2638. + autowaf.check_pkg(conf, 'sigc++-3.0', uselib_store='SIGCPP', atleast_version='2.0', mandatory=True)
  2639.  
  2640. def build(bld):
  2641. obj = bld.shlib(features = 'cxx cxxshlib', source=libztkmm_sources)
  2642. diff --git a/libs/vamp-plugins/Onset.cpp b/libs/vamp-plugins/Onset.cpp
  2643. index 03e35ba3fe..5e472b335e 100644
  2644. --- a/libs/vamp-plugins/Onset.cpp
  2645. +++ b/libs/vamp-plugins/Onset.cpp
  2646. @@ -15,7 +15,7 @@
  2647. */
  2648.  
  2649. #ifdef COMPILER_MSVC
  2650. -#include <ardourext/float_cast.h>
  2651. +#include <cmath>
  2652. #endif
  2653. #include <math.h>
  2654. #include "Onset.h"
  2655. diff --git a/libs/vamp-plugins/OnsetDetect.cpp b/libs/vamp-plugins/OnsetDetect.cpp
  2656. index c2b6d68dbc..1298597f30 100644
  2657. --- a/libs/vamp-plugins/OnsetDetect.cpp
  2658. +++ b/libs/vamp-plugins/OnsetDetect.cpp
  2659. @@ -13,7 +13,7 @@
  2660. */
  2661.  
  2662. #ifdef COMPILER_MSVC
  2663. -#include <ardourext/float_cast.h>
  2664. +#include <cmath>
  2665. #endif
  2666. #include "OnsetDetect.h"
  2667.  
  2668. diff --git a/libs/vamp-plugins/PercussionOnsetDetector.cpp b/libs/vamp-plugins/PercussionOnsetDetector.cpp
  2669. index 35dd8ca668..67315b9d36 100644
  2670. --- a/libs/vamp-plugins/PercussionOnsetDetector.cpp
  2671. +++ b/libs/vamp-plugins/PercussionOnsetDetector.cpp
  2672. @@ -35,7 +35,7 @@
  2673. */
  2674.  
  2675. #ifdef COMPILER_MSVC
  2676. -#include <ardourext/float_cast.h>
  2677. +#include <cmath>
  2678. #endif
  2679. #include "PercussionOnsetDetector.h"
  2680.  
  2681.  
Add Comment
Please, Sign In to add comment