Commit Graph

929 Commits

Author SHA1 Message Date
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
Paul Davis
a59c217205 extend PBD::Debug API to provide a method that doesn't send to debug Transmitter 2023-08-30 16:06:13 -06:00
Paul Davis
076cb86912 next iteration of changes to handle time domain bounces as undoable 2023-08-14 23:42:08 -06:00
Paul Davis
0223be5312 pbd: fairly unconscionable that Undo stuff in libpbd is not namespaced, so now it is 2023-08-07 16:33:16 -06:00
Paul Davis
afe5331a0b pbd: fairly unconscionable that Command in libpbd is not namespaced, so now it is 2023-08-07 16:33:16 -06:00
Robin Gareus
c9929698ee Implement FileArchive progress/cancel
* Use PBD::Progress API
* Allow to cancel extraction and compression
* Fix querying download size
2023-05-19 03:08:22 +02:00
Robin Gareus
65f2be76f6 Move Ardour::Progress to PBD::Progress
This will allow PBD::Filearchive to properly report progress.
It is also a generally useful API and deserves to be in libpbd.

Temporarily keep Ardour::Progress as alias
2023-05-19 00:35:20 +02:00
Robin Gareus
df298c6046 Add API to sanitize UTF-8 strings 2023-04-26 17:25:24 +02:00
John Emmas
40738b2bee A couple of extra requirements for DEBUG_THREAD_PRINT 2023-04-24 14:51:04 +01:00
Paul Davis
35b5861195 try to avoid output pthread_t as-is, due to MSVC etc. 2023-04-23 11:26:00 -06:00
Paul Davis
8cc16f2b81 convert std::cerr output to DEBUG_TRACE 2023-04-22 14:38:44 -06:00
Paul Davis
2aee4765e9 don't try to print pthread_self() 2023-04-21 15:38:40 -06:00
Paul Davis
f718279949 surfaces & event loops: i really mean no more request buffer factories 2023-04-21 13:55:58 -06:00
Paul Davis
b0586763ba libpbd: changes to pre-registration of signal emitting threads
There is no need to preallocate request buffers for these threads - the event
loops that require them can allocate them when they discover and register the
pre-registered threads. This also means that event loops do not need to
register request buffer factories.
2023-04-21 13:43:46 -06:00
Paul Davis
7ad0deff10 abstractui: don't register self as a sending thread
if thread A emits a signal that is handled by thread A, no request buffers are
involved.
2023-04-21 12:16:37 -06:00
Paul Davis
4a2c27ed6d abstractui: provide a message if an event loop wakes but finds no work
(this only occurs for debug builds)
2023-04-21 12:16:37 -06:00
Paul Davis
6e65e9c82f abstractUI: pseudo-no-op: debug trace message expansion, and some reformatting 2023-04-21 12:16:37 -06:00
Paul Davis
5d023b4c60 libpbd: fix an important thinko for cross-thread signal architecture
The old code assumed that the thread that created a request buffer for a given
signal-emitting thread would be the latter thread, and thus a thread-local
pointer to the request buffer could be used. This turns out not to be true: the
GUI thread tends to be responsible for constructing the request buffers for
pre-registered threads.

That mechanism has been replaced by using a RWLock protected map using
pthread_t as the key and the request buffer as the value. This allows any
thread to create and register the request buffers used between any other pair
of threads (because the lookup always uses a pthread_t).

The symptoms of this problem were a signal emitted in an audioengine thread
that was propagated to the target thread, but when the target thread scans its
request buffers for requests, it finds nothing (because it didn't know about
the request buffer). In a sense, the signal was successfully delivered to the
target thread, but no meaningful work (i.e the signal handler) is performed.
2023-04-21 12:16:37 -06:00
Paul Davis
074516cdb4 libpbd: provide access from a ScopedConnection to the underlying UnscopedConnection 2023-04-21 12:16:37 -06:00
Paul Davis
5dc75694f0 libpbd: fix return type of Signal<>::size() 2023-04-21 12:16:37 -06:00
Nil Geisweiller
57a5f96a98 NO-OP: use Tab to indent 2023-04-21 01:00:41 +02:00
Robin Gareus
295dbd8e1e Make RCU reader return a const pointer (omnibus commit) 2023-04-08 00:15:37 +02:00
Robin Gareus
8075b55919 Fix amiguity in atomic load
operator _Tp() const volatile _NOEXCEPT {return load();}
operator _Tp() const _NOEXCEPT  {return load();}
2023-03-25 00:07:56 +01:00
Paul Davis
45490bf43f more functional tempo mapping 2023-03-24 14:19:16 -06:00
Paul Davis
4137271188 int62_t: use explicit memory order for all loads and stores
Also, improve implementation of CAS loops for operator <X>=.

Ideally, we ought to test this on ARM, both before and after.
2023-03-24 14:19:15 -06:00
Paul Davis
fe17b98079 use explicit memory order for rcu reader/write exclusion 2023-03-24 14:19:15 -06:00
Paul Davis
a486fba3e9 std::atomic - 2nd batch of changes to convert from glib to std::atomic 2023-03-24 14:19:15 -06:00
Paul Davis
4ba4cd69ff switch from glib atomic to std::atomic (libs edition) 2023-03-24 14:19:15 -06:00