Commit Graph

393 Commits

Author SHA1 Message Date
Mads Kiilerich 8e7ef0d42c
PulseAudio: use correct casing
This will also change the internal backend name, so it will miss the
previous 'config' setting '<State backend="Pulseaudio" ...'` and the
session file's '<EngineHints backend="Pulseaudio" ...'. But that is no
big deal after upgrading. Especially after the backend has been broken
for some users for a while.
2022-11-04 13:44:55 +01:00
Robin Gareus 2cf59a988c Handle tempo-map changes in sync from the calling thread
This is required to collect relevent undo/redo information, notably
automation-data changes from Playlist::update_after_tempo_map_change and
DiskReader::playlist_ranges_moved.

The realtime thread should not move regions to begin with, and debug
builds woudl also assert since no undo operation was started.
2022-10-27 08:40:09 -06:00
Robin Gareus 3ca0f4e43d
Prepare API to resample session to engine when SR mismatches 2022-09-21 00:34:03 +02:00
luz paz 1e640563d6
Fix source comment typos in `libs/ardour`
Found via `codespell`
2022-05-11 00:14:28 +02:00
Robin Gareus 1809b6ae9a
Reset port resampler after freewheeling
This clears out any data potently left there by export processing.
Previously this could cause an audible click.
2022-05-10 16:01:39 +02:00
Paul Davis 7c3268d12f temporal: TempoMap::use() returns a const ptr to enforce semantics (library version)
This commit leaves two issues outstanding:

1. unclear/ugly semantics for drag operations that reset the GUI thread's tempo map to the writable copy
2. undo/redo for the tempo map

These will be addressed in future commits
2022-04-08 11:58:04 -06:00
Paul Davis 22b50c1716 ensure that Session handles tempo map changes synchronously in the main RT process thread 2022-03-14 14:03:07 -06:00
Paul Davis da95a0a0ee replace sample rate callback used for superclock<=>sample conversion
Now using a globally-scoped static variable which is updated by the
AudioEngine whenever an SR change occurs. Defaults to 48kHz and can
be used even before there is a backend.
2022-03-14 14:03:07 -06:00
Robin Gareus 24bbf403b9
Replace Glib::Threads with PBD::Thread (1/2) 2022-03-01 01:33:49 +01:00
Robin Gareus a8559c8741
Remove unused variable 2022-03-01 01:33:21 +01:00
Robin Gareus 6900facef2
Fix potential deadlock
block_processing() may hold the process-lock, waiting
for the latency-lock. at the same time audio-engine
may hold the latter, trying to acquire the former.
2022-02-02 14:16:50 +01:00
Robin Gareus f103b984ab
Fix bounce + callback concurrency
Prevent Session::write_one_track to commence while latency
callback is already in progress. See also
* 19067f8c87
* 2eaa0183ef
2022-02-02 00:27:35 +01:00
Robin Gareus 19067f8c87
Another refinement to address bounce + callback concurrency
see also 2eaa0183ef
2022-02-01 23:49:38 +01:00
Robin Gareus 2eaa0183ef
Fix bounce + latency update concurrency
When bouncing Region or Range, Session::write_one_track()
blocks processing, but takes no process-lock.

It is possible that a latency-callback arrives at the same
time while Route::bounce_process is active and calls ::run.

This can trigger a delayline.cc  Assertion `lm.locked ()' failed
in either thread.

Now latency-callbacks are postponed until the session can
process normally again
2022-02-01 21:40:11 +01:00
Robin Gareus 5925ee0b7c
Prevent processing until buffersize change is complete
This fixes async callback from CoreAudio via
AudioDeviceAddPropertyListener. Apparently in rare cases it can
happen that the property listener calls back concurrently with
processing on M1 machines using Rosetta.

https://pastebin.com/upvc9LTc Thread 44 vs. Thread 32

May also be caused by plugin(s) taking a long time to
change buffersize. Processing continues even though the
buffersize callback has not yet completed.

PS. I have not been able to reproduce this on an Intel
machine, even with excessive buffersize changes. However
since buffersize changes cannot (usually) happen concurrently
with processing, taking the lock is reasonable.
2021-10-04 22:30:08 +02:00
Robin Gareus e5599d1c85
Fix div/zero, allow switching backends
This is another attempt replacing 1288262ca7,
which performs better.
2021-09-15 17:52:59 +02:00
Robin Gareus 3195fb720a
Fix latency signal emission sequence when using JACK
Capture latency needs to be updated before playback latency,
various internal parts depend on this order (which is also
the default for libjack itself).
2021-09-14 22:03:51 +02:00
Paul Davis c64db47b37 use new libtemporal sample rate mechanism (libs edition) 2021-08-13 12:51:31 -06:00
Paul Davis ae01dafcce use Temporal::set_thread_sample_rate() rather than explicit assignment 2021-08-13 12:51:30 -06:00
Paul Davis 64fd52c380 ensure that AudioEngine backend-created threads have tempo map related thread private vars set 2021-08-13 12:51:30 -06:00
Paul Davis 8d1e999be4 libardour: reset perf meters after warmup period is over 2021-06-13 12:21:08 -06:00
Paul Davis 1777cf8f69 add some initial timing points for dsp stats 2021-06-11 18:55:24 -06:00
Robin Gareus 7ce43739e8
Tweak sched priorities use given and 4 levels below. 2021-06-10 14:38:45 +02:00
Robin Gareus 444af7b3e8
Fix client_real_time_priority() calls (backend vs engine) 2021-06-10 03:17:45 +02:00
Robin Gareus 31b709b7ff
NO-OP: rename variable, avoid ambiguities
Portmanager uses "ports" as local variable in various places
(usually vector<string>). While the compiler is fine with that,
it is confusing when debugging or reading code.
2021-05-06 21:21:47 +02:00
Robin Gareus 5957e14259
Remove unused #include<> (2/2)
PBD::stacktrace() is not used nor needed by default.
It should be used sparingly.
2021-05-05 17:57:16 +02:00
Robin Gareus cc7b8b1bc5
gcc-11 compat, volatile atomic variables (1/2)
"While 'atomic' has a volatile qualifier, this is a historical
artifact and the pointer passed to it should not be volatile."

Furthermore "It is very important that all accesses to a
particular integer or pointer be performed using only this API"
(from https://developer.gnome.org/glib/2.68/glib-Atomic-Operations.html)

Hence initialization of atomic variables is changed to also use
this API, instead of directly initializing the value.

This also fixes a few cases where atomic variables were
accessed directly.

see also libs/pbd/pbd/g_atomic_compat.h
2021-03-22 15:30:07 +01:00
Robin Gareus 4a5b355d3d
Handle JACK latency callbacks in sync with process thread #8304
see also b5e479dfc3
2021-02-20 00:46:47 +01:00
Robin Gareus 01502c6805
Allow to set pretty name for all port 2021-01-18 03:18:20 +01:00
Robin Gareus 8ba7df9105
Add input port signal meters, scopes and monitors 2021-01-08 18:39:56 +01:00
Robin Gareus 32a0c6a3ff
Drop TMM ports when closing session, or backend goes away
TMM ports cannot exist without a backend.
This fixes crashes where the PortEngine is re-initialized
(backend change):

Previously, TMM ports were only dropped (and recreated)
in TMM::restart() called from ARDOUR::init_post_engine().
When starting a new backend the old one is already destroyed,
but TM still held reference to Ports owned by that backend.
Calling the port's d'tor caused a memory corruption trying to
acquire the backend's port_callback_mutex:

e.g. When creating new session with a different backend
from a running instance, or unit-test after call to
AudioEngine::destroy(): https://pastebin.com/4D6pLA5s
2020-10-22 07:38:00 +02:00
Robin Gareus 1796ee60b2
Clean up b5e479df and expose API to queue latency-updates 2020-07-12 00:38:56 +02:00
Robin Gareus b5e479dfc3
Handle JACK latency callbacks in sync with process thread #8304
This is only relevant with JACK, where different implementations
use threads for the latency callback.

With jack 2, jack_port_register() blocks and the jack_latency_callback
arrives in a different thread: https://pastebin.com/mitGBwpq
with jack 1 the callback arrives in sync

In either case this usually happens while
_adding_routes_in_progress == true and Ardour holds the process-lock,
because jack2 can process in parallel with reconfiguring latency

See also 1983f56592
2020-07-12 00:15:26 +02:00
Robin Gareus ef94663d1c
Overhaul MIDI Clock generator
* Fix absolute time alignment, sync clock ticks on exact beats
* Fix start/cont sync to MIDI Clock **Beats** (MIDI Clock / 6)
* Send timecode from engine (not session) - vari-speed independent
* Special case MClk port, don't /resample/
* Support pre-roll, sync start.
2020-05-31 23:46:28 +02:00
Robin Gareus 8ffcdc9d02
Send LTC timecode from engine context 2020-05-07 20:43:22 +02:00
Robin Gareus daf9fe2550
Tweak engine startup, shorten initial silence timeout
see also 23baeee829
2020-04-16 16:47:08 +02:00
Paul Davis 92005cd992 fix 2 additional "resets" of shared_ptr<PortPtr> 2020-04-07 17:11:50 -06:00
Paul Davis 76245107c7 fix 2 additional "resets" of shared_ptr<PortPtr> 2020-04-07 17:02:08 -06:00
Paul Davis b9cb306e8b use shared_ptr to manage backend port lifetimes (Pulse,ALSA,Dummy,JACK)
JACK is not yet finished.

Changes also include minor reformatting and a spelling correction (latecies to latencies)
2020-04-07 13:23:49 -06:00
Robin Gareus 23baeee829
Tweak engine startup, initial silence
This can help when running with very low latency and the
initial process callback is [indirectly] expensive.

E.g. load a heavy session the a RPi4, initial setup can pull
in a lot of data, which blocks the bus.

In particular with the ALSA backend this can lead to poll timeout
which effectively stops the backend.
2020-03-30 15:20:54 +02:00
Robin Gareus c365c6cdb2
Set thread-names (libs) 2020-03-29 14:56:22 +02:00
Robin Gareus f81442c3bf
Engine: Silence outputs for 1/2 second when loading a session
This allows for caches to warm up, background worker threads to
spin up and things settle down. This also prevents initial
audible artifacts of live input.

In almost all cases this completes before the GUI is brought up.
2020-03-29 01:44:03 +01:00
Paul Davis e202b64951 variable rename and comment 2020-03-27 10:25:00 -06:00
Paul Davis 1e474afbce fix typo that passed wrong value as 2nd parameter to Session::plan_master_strategy() 2020-03-22 10:57:54 -06:00
Paul Davis 8296a030a5 redesign chasing the transport master
Substantive comments associated with code in Session::plan_master_strategy.

Known not to work for reverse TC. Also, the JACK related code has not yet been tested
2020-03-20 17:38:38 -06:00
Robin Gareus 44440f9316
Add new requirements from AudioEngine::stop to ::drop_backend
This fixes an issue that after changing backends (::set_backend),
the session-transport was in inconsistent state. If it was rolling,
it continued to roll with "stop" being unavailable.
2020-01-27 20:26:06 +01:00
Robin Gareus df8c0d949e
Engine: debug-print alignment 2020-01-24 19:15:21 +01:00
Robin Gareus d8c63568a5
Clear AudioEngine Error at app start 2019-12-04 19:02:16 +01:00
Robin Gareus 512c27d277
Fix buffer-overflow when vari-speeding
Session::process() can call split-cycle which offset the
buffer pointers. When vari-speeding at speed > 1.0, the
engine also splits the cycle every n_samples, to not exceed
the configured buffersize. This needs to take prior buffer
offsets into account.
2019-11-21 23:37:31 +01:00
Paul Davis 47672fceec rename method argument to better reflect its intended role 2019-11-04 12:52:34 -07:00