Commit graph

1708 commits

Author SHA1 Message Date
Paul Davis
d917d7b351 fix actual x_assert macro definition 2022-06-22 13:31:08 -06:00
Paul Davis
df641765ec add new header for x_assert() macro 2022-06-22 13:31:08 -06:00
Paul Davis
24f1a65d5f use C style cast in C code, rather than C++ constructor 2022-06-22 13:31:08 -06:00
Paul Davis
48a109e8c8 fix snprintf buffer size warning 2022-06-22 13:31:08 -06:00
Paul Davis
cd4549aff7 fix signed/unsigned warning 2022-06-21 17:31:50 -06:00
Paul Davis
dc4235efbe fix left-shift of negative value warning 2022-06-21 17:31:17 -06:00
Paul Davis
32b41037b5 libpbd: do not use debug transmitter inside BaseUI::signal_new_request() to avoid recursion 2022-06-13 13:43:31 -06:00
Paul Davis
20997dfa78 add new exception-safe RAII object, that increments/decrements its argument 2022-06-13 10:51:04 -06:00
Robin Gareus
95aa39d1c4
Update call_slot() API, inform caller if slot cannot be queued
It can happen that ::get_request() returns NULL if the
EventPool is full. In that case the slot is never called.

In this case the caller can now take action.
2022-06-09 01:46:27 +02:00
Robin Gareus
87ee609339
Amend previous commit, fix debug print format 2022-06-03 05:32:19 +02:00
Robin Gareus
fd5d290217
Fix mach thread time constraints on M1
or any system where timebase is not 1 tick per ns.
2022-06-03 05:27:42 +02:00
Robin Gareus
c2cff575b7
Add debug info to track down M1 time-constraint issue 2022-06-03 03:52:43 +02:00
Robin Gareus
60db5a827f
Use SYS_futex instead of __NR_futex
Use the C library definition for portability; also test
for support instead of unconditionally enabling it.
2022-05-30 21:56:49 +02:00
Paul Davis
12e5042ece libpbd: add muldiv() to compute v * (n/d) without overflow 2022-05-27 12:47:44 -06:00
Paul Davis
e1f5fb0206 libpbd: change GlibEventLoopCallback to use C API not C++
We discovered in the past that the C++ API for GSource/Glib::Source has some fatal and unfixable flaws. Copy similar
code and just use the C API for GSource instead
2022-05-19 22:24:43 -06:00
Robin Gareus
a811583380
Add API to query registered controllers 2022-05-19 20:08:08 +02:00
Paul Davis
4c1506e50e add copyright notices 2022-05-16 15:41:56 -06:00
Paul Davis
968533cc23 (re)add mechanism for a callback in any glib event loop executed before the loop "executes"
This is based on code from earlier commits that were later reversed, but we need some mechanism
to ensure that threads have a thread local tempo map ptr set. The big difference is that this
time we do not implement this for all instances of an AbstractUI - implementation is left to
each thread/event loop
2022-05-16 15:24:52 -06:00
itmuckel
9178ca635a
Remove unused imports and modernize stateful.cc 2022-05-13 23:07:49 +02:00
Robin Gareus
40fa6e2023
Improve PBD::Semaphore performance
Skip syscall if no threads are waiting and decouple atomic
value from futex address so that FUTEX_WAIT does not fail.
2022-05-12 05:27:27 +02:00
Robin Gareus
f849f3ce2c
Use futex semaphores on Linux only 2022-05-12 00:56:33 +02:00
Robin Gareus
5ca76789c5
Allow to query capacity of MPMC queue
This is in preparation to grow the queue as needed.
2022-05-12 00:40:31 +02:00
Robin Gareus
34678c094a
Implement Futex semaphore 2022-05-11 23:55:41 +02:00
Robin Gareus
f7e917c123
Potential fix for M1 x-thread events
On M1, the cross-thread channel sets G_IO_PRI in addition to G_IO_IN
this breaks various assumptions in receivers, which test for ~G_IO_IN
as error condition.
2022-05-02 00:02:33 +02:00
Paul Davis
3d860b9665 libpbd: do not use DEBUG transmitter from inside AbstractUI<T> request methods
This will lead to recursion, since delivering the debug msg goes through a request method.

Discovered by running with -D all
2022-04-26 22:04:08 -06:00
Robin Gareus
9ce91e2952
NO-OP: clang-format 2022-04-23 23:12:13 +02:00
Robin Gareus
c1d6c0690e
Fix poll() edge case on macOS, clean up logic
Return from poll_for_request() when CrossThreadChannel is
closed/destroyed. -- see also f4166fb61d

This also cleans up poll API usage, and check for nonnegative
return value is added.
2022-04-23 23:12:10 +02:00
Robin Gareus
defc902571
Allow to use Destructible as virtual base class
This is in preparation for a pure-virtual base class for
PluginInsert to expose `DropReferences` in the virtual base.

```
class PlugInsertBase : virtual public PBD::Destructible
class PluginInsert : public Processor, public PlugInsertBase
class Processor : public SessionObject
class SessionObject : public PBD::StatefulDestructible
```
2022-04-14 16:35:02 +02:00
luz paz
fb55878375
Fix source typos (heirarchy->hierarchy) 2022-04-08 21:38:00 +02:00
Paul Davis
7bf89ce109 Constification: make Stateful::get_state() const, with all other required const-ness added (libs) 2022-04-06 21:56:59 -06:00
Robin Gareus
e15fb0dc38
Fix unset of LIBRARY_PATH environment variable
see also 82d491cb80
2022-04-01 20:50:28 +02:00
Robin Gareus
82d491cb80
Allow to unset LD_LIBRARY_PATH on exec
This is useful when using distro-packaged video-tools
(e.g. on Linux/ARM), or when running post-export commands.
2022-04-01 18:19:55 +02:00
Robin Gareus
abbf1ca698
Allow to get exit status from child processes 2022-03-11 18:18:06 +01:00
Robin Gareus
84c51a1411
Fix BaseUI x-thread signal vs thread-start race
Control surfaces c'tor usually subscribe to signals e.g.
PortConnectedOrDisconnected. This happens after the parent BaseUI
is created, but before set_active() -> BaseUI::run() is called.

At this point in time there is no run_loop thread.

There are two options to handle AbstractUI::call_slot():

 A. Queue the event in the event-loop, using the thread-local
    request buffer of the caller. Then hope the BaseUI
    thread is started, and calls ::handle_ui_requests() before
    the memory pool runs out of space.

 B. Handle the event in the calling thread. -- This may not be
    rt-safe and may call functions with locks held by the caller.
    It will however not accumulate events.

This takes approach (B). If _run_loop_thread is NULL, directly
handle the signal.

In the past, prior to 50abcc74b5, approach (A) was taken.
NULL never matched Glib::Threads::Thread::self().

This also reverts a prior attempt (e417495505) to address this issue.
2022-03-02 21:19:12 +01:00
Robin Gareus
e417495505
Fix possible race (BaseUI creation vs x-thread signal-emission)
When a BaseUI is being created, signals can arrive before the
_run_loop_thread is running, which can trigger an assert in
BaseUI::caller_is_self().
2022-03-01 17:19:20 +01:00
Robin Gareus
50abcc74b5
Replace Glib::Threads with PBD::Thread (2/2) 2022-03-01 01:34:35 +01:00
Robin Gareus
e515e73db6
Implement a replacement for Glib::Threads::Thread
This is mainly because Glib::Threads (g_system_thread_new)
uses pthread on Un*x, but on Windows relies on GThreadWin32
(HANDLE)_beginthreadex

This later causes issues e.g. in BaseUI::run()

```
unhandled exception (type Glib::Error) in signal handler:
domain: g_thread_error
code  : 0
what  : Error setting new thread priority: The parameter is incorrect.
```
2022-03-01 01:33:08 +01:00
Paul Davis
baf2323798 add PBD::PropertyChange::dump (std::ostream&) to make it easier to see what changed 2022-02-09 10:08:01 -07:00
Robin Gareus
c17fbd5abc
Fix poor_mans_glob, ~' for $HOME' is only valid at the start of a path 2022-02-01 15:47:54 +01:00
Robin Gareus
f7b826841b
Log Thread-name in stacktrace 2022-01-26 00:17:49 +01:00
Mads Kiilerich
8bb91099c5 wscript: drop configure statements already present in the top level wscript
Avoid repeated pointless configure messages like:
Checking for 'g++' (C++ compiler!)                   : /usr/lib64/ccache/g++
Checking for 'gcc' (C compiler)                      : /usr/lib64/ccache/gcc
2022-01-22 22:19:03 +01:00
Robin Gareus
beb0a96f42
API to directly retrieve XML child content 2022-01-13 00:09:55 +01:00
Robin Gareus
30539716ca
Fix various Wcast-qual
g_atomic_int_get() requires a non-const pointer, however
many APIs are declared virtual const, so const_cast<> is
preferred over an API change.
2022-01-10 00:06:20 +01:00
Robin Gareus
1f5649ef28
Fix vfork edge-case
Calling c_str() after vfork is prohibited after a successful vfork.
Also the string needs to remain in scope until exec() completed.
2021-12-31 01:39:39 +01:00
Robin Gareus
b2f0d31630
Cont'd work on concurrent Signal, Connection destruction
see also 992c727959
and 7580d6aba7

Spin to prevent race between d'tor setting `in_dtor`
and acquiring Signal::_mutex.
2021-11-21 04:12:24 +01:00
Robin Gareus
992c727959
Cont'd work on concurrent Signal, Connection destruction
See also 7580d6aba7
2021-11-21 03:27:50 +01:00
Robin Gareus
7580d6aba7
Fix race condition when ~Signal and ~ScopedConnection run concurrently
Previously a deadlock was possible:

Thread 1:
  ~ScopedConnection ()
  -> Connection::disconnect ()
     takes Connection::_mutex             <<<< 1
  -> _signal->disconnect (shared_from_this ())
  -> Signal::disconnect ()
     takes Signal::_mutex                 <<<< 2

Thread 2:
 ~Signal ()
     takes Signal::_mutex                 <<<< 2
  -> Connection::signal_going_away ()
     takes Connection::_mutex             <<<< 1
2021-11-20 23:14:59 +01:00
Paul Davis
9e763c2672 remove all dangling event-loop-precall code 2021-10-11 17:48:53 -06:00
Robin Gareus
a2a36de98f
Fix minor memory leak when querying Windows registry 2021-10-11 18:20:07 +02:00
Robin Gareus
ba2a2cb654
Implement natural-sort spaceship operator 2021-10-08 04:12:32 +02:00