Commit Graph

1598 Commits

Author SHA1 Message Date
2d0b0defdf Add a clean clang-tidy configuration
This configuration just suppresses the necessary clang-* checks which are
enabled by default.  This way has a bit of file spam, but is nice because
different components (in particular, ones actually internal to ardour) can be
audited/strengthened independently.
2023-09-09 23:42:18 -04:00
4969fb9e0b libpbd: tweak for printing pthread ID (windows is int/*nix is ptr) 2023-08-31 10:34:48 -06:00
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
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
f65e0b85a8 libpbd: add operator<< for PropertyChange 2023-08-30 16:06:13 -06:00
7130deafdf fix AbstractUI redefine of DEBUG_TRACE to still use PBD::debug_print-ish stuff 2023-08-30 16:06:13 -06:00
37f859197b use PBD::DEBUG::Threads as a toggle to show thread ID/name with debug output 2023-08-30 16:06:13 -06:00
a59c217205 extend PBD::Debug API to provide a method that doesn't send to debug Transmitter 2023-08-30 16:06:13 -06:00
076cb86912 next iteration of changes to handle time domain bounces as undoable 2023-08-14 23:42:08 -06:00
0223be5312 pbd: fairly unconscionable that Undo stuff in libpbd is not namespaced, so now it is 2023-08-07 16:33:16 -06:00
afe5331a0b pbd: fairly unconscionable that Command in libpbd is not namespaced, so now it is 2023-08-07 16:33:16 -06:00
2d5ac04ae1
pthread_setname_np is available with GNU/mingw 2023-06-17 23:49:47 +02:00
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
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
4b77ecbe83
Sanitize XML values to be valid UTF-8 (#9317)
This prevents any non UTF-8 strings to leak into
Ardour XML files, which can make the session unloadable.
2023-04-26 17:43:52 +02:00
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
John Emmas
81d7a51498 Minor change to commit #35b5861195 2023-04-24 12:40:36 +01:00
35b5861195 try to avoid output pthread_t as-is, due to MSVC etc. 2023-04-23 11:26:00 -06:00
8cc16f2b81 convert std::cerr output to DEBUG_TRACE 2023-04-22 14:38:44 -06:00
2aee4765e9 don't try to print pthread_self() 2023-04-21 15:38:40 -06:00
f718279949 surfaces & event loops: i really mean no more request buffer factories 2023-04-21 13:55:58 -06:00
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
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
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
6e65e9c82f abstractUI: pseudo-no-op: debug trace message expansion, and some reformatting 2023-04-21 12:16:37 -06:00
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
074516cdb4 libpbd: provide access from a ScopedConnection to the underlying UnscopedConnection 2023-04-21 12:16:37 -06:00
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
295dbd8e1e
Make RCU reader return a const pointer (omnibus commit) 2023-04-08 00:15:37 +02:00
0b8d5d3dc5
Tweak Window system-exec, wait for process to terminate 2023-04-05 00:16:37 +02:00
473f575a05
Catch Glib::ConvertError when checking for files
This fixes some edge-cases when scanning recent sessions
in get_state_files_in_directory() and likely some other
places that use run_functor_for_paths in case the folder
contains files with non UTF-8 names.
2023-04-03 22:10:11 +02:00
3715154a8e
Allow concurrent child processes
When multiple child processes are running, closing the
stdin of one child did not send EOF or cause POLLNVAL,
as long as a dup()'ed filedes still existed.

This fixes an issue when running an mp3 encoder while the
video monitor is visible, and will allow to concurrently
run multiple mp3 encoders or other child processes.

Previously this caused Ardour to hang indefinitely in CmdPipeWriter
```
 _proc->close_stdin();
 _proc->wait(); // << here
```
2023-03-25 06:43:46 +01:00
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
45490bf43f more functional tempo mapping 2023-03-24 14:19:16 -06:00
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
fe17b98079 use explicit memory order for rcu reader/write exclusion 2023-03-24 14:19:15 -06:00
a486fba3e9 std::atomic - 2nd batch of changes to convert from glib to std::atomic 2023-03-24 14:19:15 -06:00
4ba4cd69ff switch from glib atomic to std::atomic (libs edition) 2023-03-24 14:19:15 -06:00
945c19b8b4 libpbd: make RCU more C++-ish 2023-03-24 14:19:15 -06:00
b35518e212 switch from boost::{shared,weak}_ptr to std::{shared,weak}_ptr
This is mostly a simple lexical search+replace but the absence of operator< for
std::weak_ptr<T> leads to some complications, particularly with Evoral::Sequence
and ExportPortChannel.
2023-03-24 14:19:15 -06:00
90c5524e7b libbd: add required <cassert> include 2023-03-24 14:19:15 -06:00
39ed528e25 std-ize: convert all boost shared/weak ptr includes to <memory>
Also fix stdint.h -> cstdint and alphabetically order std includes
2023-03-24 14:19:15 -06:00
eeaf0bdadc
Fix non-intel arch builds (cpuid.h header) 2023-02-09 20:54:46 +01:00
Ayan Shafqat
bb31125c94
Fix CPUID to detect AVX512F
CPUID is part of x86_64 ISA to query CPU features. In order to determine
AVX512F ISA extension, EAX and ECX needs to be set to 7 and 0
respectively before invoking `cpuid` instruction. This commit also
removes inline assembly for __cpuid in favor of using compiler provided
intrinsic functions. Both GCC and clang provides __cpuid like function
via __cpuid_count intrinsic.

This commit also creates a portable wrapper over compiler intrinsic
functions, __cpuid and __cpuidex. `cpuid' provides base level ISA query
and `cpuidex` provides extra extension information like AVX512F. These
wrappers lean towards MSVC like API.

References:
CPUID Docs: https://en.wikipedia.org/wiki/CPUID

GCC's ``docs" on __cpuid_count:
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/i386/cpuid.h

Clang's docs on __cpuid_count:
https://clang.llvm.org/doxygen/cpuid_8h.html

MSVC's docs on __cpuid and __cpuidex:
https://learn.microsoft.com/en-us/cpp/intrinsics/cpuid-cpuidex
2023-02-08 23:20:20 +01:00
Ayan Shafqat
bf8fced073
Add CPU detection 2023-02-04 23:07:17 +01:00
John Emmas
2ff05d9e9d class 'PBD::Configuration' now needs to be exportable 2023-01-28 17:44:11 +00:00
68f4c7ce8e add upcase() method; remove upcase version of internationalize() 2023-01-27 15:13:27 -07:00
3c1c6e7b68 continued work on use of Metadata in various Configuration objects (libs edition) 2023-01-27 15:13:27 -07:00