Commit Graph

868 Commits

Author SHA1 Message Date
David Robillard
bdacfb8724 Fix invalid use of Doxygen "@param" command
This is never for inline references to parameters, only for starting parameter
documentation blocks.  The "@p" command is for this, although unfortunately
Doxygen doesn't actually do anything with it and it's just an alias for code
text.
2022-10-30 20:44:28 -04:00
Mads Kiilerich
004b32b91e Update tracker/reference URLs to prefer HTTPs 2022-10-24 04:59:20 +02:00
Robin Gareus
14da117bc8 Add explicit round/floor integer multiply/divide
This fixes various rounding issues. Notably superclock to sample
conversion must always round down when playing forward.

`::process (start, end, speed = 1)` uses exclusive end.
Processing begins at `start` and end ends just before `end`.
Next cycle will begin with the current end.

One example where this failed:
 - New session at 48kHz
 - Change tempo to 130 BPM
 - Enable snap to 1/8 note
 - Snap playhead to 1|3|0
 - Enable Metronome
 - Play

`assert (superclock_to_samples ((*i).sclock(), sample_rate()) < end);`

end = 177231 samples == superclock 1042118280
A grid point is found at superclock 1042116920 (that is < 1042118280).
However converting it back to samples rounded it to sample 177231 == end,
while actual location is 1360 super-clock ticks before end.

The metronome click has to be started this cycle, since the same
position will not be found at the beginning of the next cycle, with
start = 177232.

Similarly a samplecnt_t t, converted to music-time and back must not be
later than the given sample.

```
timepos_t tsc (t);
assert (timepos_t::from_ticks (tsc.ticks ()).samples () <= t);
```

IOW. When playing forward, all super-clock time between 1|1|0 and 1|1|1
should round down to 1|1|0. "We have not yet reached the first tick".
2022-10-22 02:10:05 +02:00
Robin Gareus
5016c950d0 Move ControllableSet up in PBD's namespace
This is in preparation to supersede AutomationControlSet
with a lower level generic std::set usable in any relevant
context.
2022-10-18 00:08:21 +02:00
Robin Gareus
ebf59d4426 Insert_or_assign properties, allow to override properties
This allows to copy a property list and then selectively
replace various properties. e.g.

```
PropertyList plist (region->properties ());
plist.add (Properties::length, len);
plist.remove (Properties::start);
```

See also 8b0ab38675
and 97f0fac7d5
This also fixes the issue referenced in
8c83149c4c
2022-10-07 00:32:14 +02:00
Paul Davis
be24b51a6b downloader: remove unnecessary header 2022-09-13 14:15:24 -06:00
Paul Davis
d087cd9465 downloader: use PBD::Thread instead of std::thread 2022-09-13 14:14:53 -06:00
Paul Davis
375daf4810 libpbd: new threader Inflater and Downlaoder classes 2022-09-13 13:53:45 -06:00
Paul Davis
2061c3780d FileArchive: minor fixes to get progress reporting working 2022-09-13 13:53:45 -06:00
Paul Davis
73331ae46a libpbd: fix decl of remove_extra_whitespaces 2022-09-07 17:56:52 -06:00
Paul Davis
5563117a1b add remove_extra_whitespace() to libpbd 2022-09-07 17:03:08 -06:00
Paul Davis
26b5700957 filearchive: extend API 2022-09-07 17:03:08 -06:00
Robin Gareus
2a7d528c5d Update and consolidate gettext.h
This fixes compilation with --no-nls on modern systems
2022-09-07 00:09:54 +02:00
Robin Gareus
effc209070 Place Pool in PBD namespace
A public class named "Pool" in the global namespace just
calls for symbol name conflicts.
2022-07-07 05:21:54 +02:00
Robin Gareus
8418e7c954 NO-OP: clang-format 2022-07-07 05:21:49 +02:00
Robin Gareus
1694c71cd5 Implement memory-pool debug-dump
This will allow to trace "POOL OUT OF MEMORY" and see
which events fill up the event/memory pool.
2022-07-07 05:21:31 +02:00
Paul Davis
0d70be3a05 miscellaneous fixes for warnings from -Wconversion 2022-07-04 22:01:48 -06:00
Paul Davis
0004ca2c41 add useful DEBUG_RESULT and DEBUG_RESULT_CAST to pbd/debug.h 2022-06-22 13:31:08 -06:00
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
cd4549aff7 fix signed/unsigned warning 2022-06-21 17:31:50 -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
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
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
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
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
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
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
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
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
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
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
ba2a2cb654 Implement natural-sort spaceship operator 2021-10-08 04:12:32 +02:00
Paul Davis
64db1367bb Change name of Stateful::apply_changes (PropertyBase) to the singular form.
Makes it slightly easier to read+parse what is happening. Yes, for a
Sequence property, the call could apply several changes, but overwhelmingly
it is used to apply a single change.
2021-09-25 16:49:51 -06:00
Paul Davis
2ed1bdd243 Remove PropertyTemplate::call() and replace with code that uses ::set()
This makes undo/redo work correctly.
2021-09-25 16:49:51 -06:00
Robin Gareus
cb81b06a5d Revert "Fix div/zero, allow switching backends"
This reverts commit 1288262ca7.
2021-09-15 17:52:53 +02:00