Commit Graph

956 Commits

Author SHA1 Message Date
John Emmas
b795d36cd3 Avoid using 'boost::aligned_storage' which is known to be problematic in MSVC builds
MS initially believed the runtime issues might be fixable in VS2015 but in fact, Boost's alignment strategy and Microsoft's alignment strategy just turned out to be incompatible:-

https://www.boost.org/doc/libs/1_65_0/libs/type_traits/doc/html/boost_typetraits/reference/aligned_storage.html
2025-06-17 09:02:24 +01:00
Robin Gareus
0803cac946 Fix optimized builds 2025-06-07 01:53:33 +02:00
Paul Davis
cc435bcd0f make connection/emission debugging of PBD::Signal more useful/informative 2025-06-06 09:07:45 -06:00
Robin Gareus
b92fa1d0e4 Use PBD::CCurl for libardour HTTP/S requests 2025-05-20 00:03:21 +02:00
Robin Gareus
4f300b5474 Migrate SSL-cert setup to libpbd, so the downloader can use it 2025-05-20 00:03:21 +02:00
Paul Davis
1c0882ba56 PBD::Signal: do not use a StackAllocator for signals with return values 2025-05-09 14:21:05 -06:00
Paul Davis
2a7bef47fa return immediately in a non-void Signal if there are no handlers
This allows r.begin(() to not refer to undefined memory
2025-05-05 21:51:23 -06:00
Paul Davis
cf84ed0041 use a std::vector to collect signal handler return values, not std::list 2025-05-04 19:21:50 -06:00
Robin Gareus
e3860844a6 Improve StackAllocator debug messages 2025-05-04 23:41:22 +02:00
John Emmas
d285ff365e Add a visibility specifier that's now needed
Following the introduction of 'Pianoroll::region_prop_change()' (commit #29833d75c92) the operator<< (for PBD::PropertyChange) now needs to be visible outside of libpbd
2025-04-19 13:33:36 +01:00
Paul Davis
ebda6bf0c5 rework PBD::Signal emission code to avoid memory allocation
We now use a stack allocator when making a copy of current connection state at
the start of the signal emission process, and when collecting results from
signal handlers in the case of a non-void return type.

These changes also include a functionally neutral reworking of how the connection
state copy is made and then used to check that a connection/handler is still
valid mid-emission.

Heap allocation will still happen if a signal has more than (currently) 512
connections. A little experimentation reveals that the maximum number of
connections is typically nroutes+1, so 512 seems like a reasonable choice
for this.
2025-04-16 09:09:57 -06:00
Paul Davis
f66f81546d fix several warnings from PBD::Signal due to a missing return call for some types 2025-04-15 22:34:49 -06:00
Paul Davis
a46f2cefb4 PBD::Signal - move connection list back into private scope (amend 86c837b0e) 2025-04-14 10:45:46 -06:00
Paul Davis
86c837b0eb provide deeper debugging of PBD::Signal emission process 2025-04-14 10:10:57 -06:00
Paul Davis
71f93d3c12 provide a stacktrace function callable directly from C (libpbd_c_stacktrace()) 2025-02-11 10:23:01 -07:00
Robin Gareus
4a99026cc9 Revert "Replace boost::aligned_storage with alignas std::array"
This reverts commit 32ff87f7f6.

This causes issues on macOS/clang
```
../libs/pbd/pbd/stack_allocator.h:152:53: note: destructor of 'StackAllocator<std::__tree_node<std::__value_type<ARDOUR::DataType, std::map<unsigned int, unsigned int, std::less<unsigned int>, PBD::StackAllocator<std::pair<const unsigned int, unsigned int>, 16>>>, void *>, 2>' is implicitly deleted because field '_buf' has a deleted destructor
  152 |         alignas(16) std::array<value_type, stack_capacity> _buf;
```
2024-11-19 18:03:23 +01:00
Alejandro Domínguez
32ff87f7f6 Replace boost::aligned_storage with alignas std::array 2024-11-17 18:43:08 +01:00
Mads Kiilerich
b4ff4f356c Make header files more self-contained - add missing Ardour and lib includes 2024-10-20 03:30:46 +02:00
Mads Kiilerich
8a5f21d8e3 Drop some unused files - avoid trying to maintain stuff that can't be tested 2024-10-20 03:11:53 +02:00
Mads Kiilerich
140670541f Use .inc.h for #include files that not are plain headers
Regular .h files *should* be self-contained and independent of previous
includes and guarded to only include once. Make it clear which files
that *doesn't* apply for at all.
2024-10-20 03:11:53 +02:00
Robin Gareus
74c4ca3e52 Reduce reliance on boost - the hard part
the rest from `tools/convert_boost.sh`.

* replace boost::function, boost::bind with std::function and std::bind.

This required some manual fixes, notably std::placeholders,
some static_casts<>, and boost::function::clear -> = {}.
2024-10-19 03:47:21 +02:00
Robin Gareus
ff95d81612 Reduce reliance on boost - the easy part
* boost::unordered_map -> std::unordered_map
* BOOST_STATIC_ASSERT/static_assert
* BOOST_FOREACH -> for
* boost::tuple -> std::tuple/g
* boost::math::isnormal -> std::isnormal
* boost::container::set -> std::set
* boost::none -> std::nullopt
* boost::optional -> std::optional
2024-10-19 03:41:16 +02:00
Alejandro Domínguez
2436b4df06 Replace boost::noncopyable with C++11 deleted copy constructors 2024-10-19 01:04:15 +02:00
Robin Gareus
bd8525e5f1 Remove deprecated PBD::SignalN 2024-10-18 20:46:31 +02:00
Robin Gareus
2d7cce44f1 Replace PBD::Signals (1/2) 2024-10-18 20:41:08 +02:00
Alejandro Domínguez
0ade0b2212 Deduplicate SignalWithCombiner<Combiner, void, A...> specialization 2024-10-18 20:41:08 +02:00
Alejandro Domínguez
16dd8528c8 Make SignalN template variadic 2024-10-18 20:41:05 +02:00
Paul Davis
75f56cd3e1 the great onceification (libs)
Replace use of #ifndef header guards with #pragma once

Modern C++, baby!
2024-10-17 07:44:31 -06:00
Paul Davis
7901b4119f we're gonna need a bigger debug set 2024-10-17 07:44:31 -06:00
Paul Davis
911ad78c06 add API to access PBD::UndoHistory member of HistoryOwner 2024-10-17 07:44:31 -06:00
Paul Davis
d30c8a1286 abstract concept of a history owner from ARDOUR::Session into libpbd 2024-10-17 07:44:31 -06:00
Paul Davis
7799adc8db make Stateful a virtual base class of StatefulDestructible
This permits dual inheritance from Stateful.
2024-10-17 07:44:29 -06:00
Robin Gareus
8115578d4e Add RT thread priority debugging 2024-10-14 21:49:56 +02:00
John Emmas
fd8808d7b8 Minor declaration issue that upsets MSVC/c++17 2024-10-13 11:39:48 +01:00
Robin Gareus
0aff098541 Fix IO Thread priority
This adds `pbd_pthread_priority` indirection to correctly get
the absolute thread priority.

and for consistency a 4 letter enum is used.
2024-10-11 10:06:49 +02:00
Robin Gareus
ed437afda7 Fix thread priorities for Windows builds 2024-09-30 19:07:53 +02:00
Robin Gareus
395833e4f8 Always use PBD API for thread priorities 2024-09-28 03:58:48 +02:00
Robin Gareus
e8445d13ec Require thread name to be passed to PBD::Thread and store thread 2024-09-28 03:16:30 +02:00
Robin Gareus
8d3ebde60e Distinguish Threads and ThreadName debugging
This also allows for -DThread to enable both.

We celebrate the 128th debug bit and look forward to
the next 64!
2024-09-28 03:15:36 +02:00
Alejandro Domínguez
867eaa0b13 Remove unused libs/pbd/pbd/stl_functors.h 2024-09-01 19:17:10 +02:00
Robin Gareus
b50477e608 Exclude monitor gain from mixer scenes 2024-07-15 00:43:51 +02:00
Robin Gareus
5b9e4fff63 Parallelize Disk I/O and RegionFx processing 2024-04-30 03:46:39 +02:00
Robin Gareus
44610c7877 Fix RCU race condition (see source for details) 2024-04-12 00:26:51 +02:00
Robin Gareus
2fe22eeab5 Fix header include, potential fix for #9649 2024-02-29 03:09:00 +01:00
Robin Gareus
6494214622 Add option to prefer file timestamps with recursive copy 2023-09-27 02:22:22 +02:00
Mads Kiilerich
c5e7e5c4df pbd: clarify int62_t comments 2023-09-20 12:51:52 -06:00
Paul Davis
bc7f25e52c libpbd: AbstractUI must call & destroy sigc::trackable callbacks in its destructor
AbstractUI IS-A BaseUI IS-A EventLoop
                       IS-A sigc::trackable

If we have sent a call_slot() request to an EventLoop that has not executed
when the object involved in the call_slot() functor is destroyed, we need to
ensure that the request is invalidated.

To do this, We register "notify" callbacks with the sigc::trackable that is a
base class of the object involved in the functor given to
call_slot(). sigc::trackable will call these "notify" callbacks from its
destructor.

So when the call_slot() functor's relevant object dies, and its sigc::trackable
base class is destroyed, it will invoke all of its the "notify" callbacks, which will
in turn call EventLoop::invalidate_request() and this hopefully marks all the
queued call_slot() functors as "do not call".

However, invalidate_request() requires a lock, and access to the lock is
granted via a pure virtual, EventLoop::slot_invalidation_lock(). In the
heirarchy cited above, this is implemented by AbstractUI.

When we destroy an AbstractUI, ~AbstractUI() is called first, and this destroys
the lock and changes the VTT so that ::slot_invalidation_lock() becomes a pure
virtual again.

Eventually we will call ~trackable() which in turns runs all the "notify"
callbacks, and then removes them. But when these callbacks end up in
EventLoop::invalidate_request(), we try to call ::slot_invalidation_lock() and
C++ will abort because of its (now) pure virtual status.

Therefore, we must invoke the "notify" callbacks before the
::slot_invalidation_lock() becomes pure, and that means inside ~AbstractUI, as
an explicit call to trackable::notify_callbacks().

This has not appeared before (remarkably), but became an issue when the
Launchpad Pro support code's main object (derived from MIDISurface and hence
from AbstractUI) "failed" to use sub-objects for its various methods. So when
it connects to, for example, the Session::RouteAddedOrRemoved signal, it is
connecting itself (derived from a sigc::trackable). When the Launchpad Pro
object is destroyed, it tries to invalidate all the call_slot() requests, but
this requires access to an event loop lock - owned by the Launchpad Pro event
loop, which is already destroyed!

Other surfaces have generally avoided this by using other objects to provide
methods of dealing with signals from libardour objects.
2023-08-30 16:06:14 -06:00
Paul Davis
d5ad9ff033 libpbd/guis: move __invalidator() into PBD::EventLoop
we allow use of/dependency on sigc::trackable there, so this is
both legal but also sensible.

Leave the macro definition of invalidator(x) in gtkmm2ext/gui_thread.h
because it doesn't hurt and makes some sense for it to be there. No
reason for a source module that needs invalidator(x) to load EventLoop
decl.
2023-08-30 16:06:14 -06:00
Paul Davis
f65e0b85a8 libpbd: add operator<< for PropertyChange 2023-08-30 16:06:13 -06:00
Paul Davis
7130deafdf fix AbstractUI redefine of DEBUG_TRACE to still use PBD::debug_print-ish stuff 2023-08-30 16:06:13 -06:00