Commit Graph

144 Commits

Author SHA1 Message Date
Robin Gareus 5e9d98dbf9
Debug Port reconnect 2023-06-07 18:13:27 +02:00
Robin Gareus 10b2380b14
Fix deadlock/race introduced in aaf301321
Port::_connections_lock must not be locked when calling
port_engine.connect().
2023-05-27 14:18:31 +02:00
Robin Gareus d5cc5b0586
Auto-connect master/monitor when switching backends 2023-05-27 00:08:48 +02:00
Robin Gareus aaf3013211
Save I/O connections per device (#9344) 2023-05-27 00:08:25 +02:00
Robin Gareus 95de61f74e
Fix race condition when closing a session
~Session calls AudioEngine::remove_session(), which fades out,
then unsets the session, and then in libs/ardour/audioengine.cc:460
```
session_removed.signal(); // wakes up thread that initiated session removal
```

Session d'tor continues, and calls Port::PortDrop(), which
unregisters all ports one at a time.

Concurrently, AudioEngine continues, and calls PortManager::silence_outputs
which gets all ports first (!), and then iterates over them.

There is a race condition which can lead to
DummyAudioBackend::get_buffer: Assertion `valid_port (port)' failed
2023-04-24 17:43:08 +02:00
Paul Davis 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
Robin Gareus 77bb262c26
Add API to check for internal port connections 2023-03-07 20:49:37 +01:00
Robin Gareus 17f2862f96
Emit signal when resampler-quality changes 2023-02-04 03:20:20 +01:00
Robin Gareus 72995741bb
Adjust resampler quality when sample-rate mismatches
This also ensures that engine/session resampling is possible
when the config `port-resampler-quality` is 0.
2023-01-31 01:07:04 +01:00
Robin Gareus 3ca0f4e43d
Prepare API to resample session to engine when SR mismatches 2022-09-21 00:34:03 +02:00
Robin Gareus e863a7dbc9
Allow to configure vari-speed resampler quality
This also allows to disable the resampler, effectively disabling
varispeed support, for the benefit of adding no additional latency.
By default 2 * 16 samples latency are added, due to port-resampler,
this is not desirable if Ardour is used as mixer only.
2022-05-24 20:41:59 +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 226dadbd19
Further reduce DSP load of debug builds
In all years of using these assert()s never triggered. Besides
there are valid_port() tests in other strategic locations that
are not periodically hit in realtime context.
2022-05-06 02:04:55 +02:00
Robin Gareus 786388b5b6
Fix connections when re-starting engine
The connection was stored by the Port where it was initiated from:

1. Connect A to B
2. Disconnect B from A

(1) Port A remembers the connection to B
(2) Port B does not know about the connection from A

Since disconnect is initiated on port B, port A still retained
the connection information.

When restarting the engine, Port::reconnect() reestablished the
connection.

This is only relevant when libardour's own connection information is
used. e.g. the session is closed without engine, or when re-starting
the engine while the session is open.
2021-11-30 19:41:39 +01:00
Robin Gareus 6b348d8183
Reconnecting unconnected ports always succeeds
PortManager::reconnect_ports emit a signal
PortConnectedOrDisconnected when Port::reconnect fails. This is
not needed in case of unconnected ports.
2021-11-01 22:57:18 +01:00
Robin Gareus a84cb976a0
Add API to query I/O latency from port-engine
This allows to get public latency ranges for any port
including Ardour's latency-compensation as well as including
any latency induced by external JACK applications.

It is mainly useful to detect ambiguous latency and to
forward public port latency of connected ports.
2021-09-14 21:39:53 +02:00
Robin Gareus f301e692a7
Expose compensated port-latency, fix ambig. latency detection
Previously Ardour only announced processor latency.
Routes that had additional latency to compensate for those
have not published this delay.

This is of no concern with internal backends, however with JACK,
Ardour reported incorrect *individual* port-latencies of
routes that perform PDC.

Since public port latency now includes delay-compensation,
some extra work is required to unset it before recalculating
latency of paths that include external ports.
2021-09-08 22:39:32 +02:00
Robin Gareus 1978d3723e
Fix latency debug messages 2021-09-08 22:39:31 +02:00
Todd Naugle ff1d5e7aeb When reconnecting ports, don't give up on first failure.
If there are multiple connections, one might fail due to missing hardware,
but the rest could still be valid.

An easy way to reproduce this was to route "mackie control out" to a device
and to the Midi tracer port. When you opened the session again, connection
from the "mackie control out" to the device would not get restored because
the Midi tracer port does not exist at session start.

This most likely caused other issues with connections when changing backends.
2021-07-13 17:47:33 -05:00
Robin Gareus 3f6bf2c451
Overhaul connection events, fix capture alignment
Previously there was only a PostDisconnect() signal.
When a port connection is made directly e.g. recorder_ui.cc
r->input()->audio(..)->connect(...), or when connecting
using an external jack control app, Ardour::IO is not informed.

no IOChange::ConnectionsChanged signal is emitted and
Track::set_align_choice_from_io() is not called. This leads to
incorrec capture alignment.

To minimize signal emission the static global PostDisconnect
is changed into a per port ConnectedOrDisconnected signal.
IOs subscribes to signals from owned ports only.
2021-06-11 20:02:39 +02:00
Robin Gareus e6bbcd415d
Remove unused methods (to query public latency) 2021-02-19 14:03:27 +01:00
Robin Gareus 3d44f39c09
Report failed connections when reconnecting ports
This is needed to update the GUI (mixer-strip I/O buttons)
when the engine is re-started with different I/O.

When Port::reconnect() cannot re-connect the port (e.g.
because the corresponding hardware port is missing), the IO object
needs o be notified -> PostDisconnect() -> IO::disconnect_check.

While the port-manager re-establishes and re-connects port,
port_manager->running() == false, and Port::get_connections()
returns the Port::_connections set (not actual engine connections).
So _connections.clear() has to be called synchronize it with
the actual engine connection state.
2021-02-04 04:41:22 +01:00
Robin Gareus 17ab174277
Slightly increase vari-speed resampler quality
This also increases i/o delay to 16 samples (was 11)
2020-09-05 23:05:53 +02:00
Robin Gareus fcd347fe0c
Fix --no-nls, i18n include order in libs -- #8361
Ardour's "pbd/i18n.h" needs to be included last,
after any include that may indirectly pull in getext or libintl.

For that reason "pbd/i18n.h" must not be used in header files either.
2020-08-19 17:39:32 +02:00
Robin Gareus d363a1740d
Reset external connection count when ports are reestablished 2020-05-08 00:20:54 +02:00
Robin Gareus d9caa7fd9a
Prepare timecode-generator direct-out
Generator ports (like TransportMaster slaves), should not be
re-sampled when vari-speeding. Instead the Timecode/Clock should
directly use the engine-speed.

For this to happen, they need to be special-cased: no re-sampler
latency, direct access to engine-buffers.
2020-05-07 20:42:53 +02:00
Robin Gareus 4fa955baf2
Fix Latency information of TransportMasterPort ports
PortManager::cycle_start() excludes these ports from being
resampled. They're directly handled by the TSM, outside of
the session.
2020-05-07 15:12:57 +02:00
Robin Gareus 842e841e0d
Remove common prefix for latency debugging
-DLatency now triggers all four:
  * LatencyCompensation (entry-points, overall flow)
  * LatencyIO (Port/IO query, set/get private/public)
  * LatencyDelayLine (Delaylines for internal sends and alignment)
  * LatencyRoute (route processor latency)
2020-04-26 21:25:07 +02:00
Paul Davis e6b12bd0aa ensure that when a Session emits Port::PortDrop, transport master ports are left in place 2020-04-24 11:50:43 -06:00
Paul Davis 5b6e2b088e show ARDOUR::Port destructor with either DEBUG::Ports or DEBUG::Destruction 2020-04-07 23:20:15 -06:00
Paul Davis 260afe85ca fix "reset" of shared_ptr<PortPtr> 2020-04-07 16:57:49 -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 9091838b82
Fix MIDI Port-latencies
Only audio ports have additional latency due to I/O re-sampling
for vari-speed playback/capture.. MIDI ports are not affected.
2020-01-08 00:40:18 +01:00
Paul Davis c144e807ef remove mistakenly left-in debug stacktrace 2019-12-16 16:18:30 -07:00
Paul Davis cd78a168b2 reinstate missing latency initialization code
Removed (mistakenly) during work on transportFSM
2019-12-16 16:13:39 -07:00
Paul Davis 302fe227b8 fix resampling ratio when stopped (corner case - not typically called) 2019-11-15 16:06:04 -07:00
Robin Gareus d171bbf337
Allow vari-speed slowdown down to 2% 2019-11-14 19:39:48 +01:00
Paul Davis bd229936ec add finite state machine to control/manage transport state 2019-09-17 18:26:03 -06:00
Paul Davis ea30642ae3 resize audio port _data buffer based on current buffer size 2019-09-17 17:14:39 -06:00
Robin Gareus a22f918d9d
Update libardour GPL boilerplate and (C) from git log 2019-08-03 15:53:16 +02:00
Robin Gareus aef75f87b7
NO-OP: whitespace, comments 2019-04-08 18:32:03 +02:00
Paul Davis dae7ea5382 add DEBUG::Destruction output for Port 2019-02-04 11:20:49 -07:00
Robin Gareus 81857a947c
Consolidate ambiguous engine API calls
available(), connected(), running() were ill-defined and
used interchangeably.
2018-11-28 15:24:47 +01:00
Paul Davis e6915e01de new transport slave/master implementation, libs/ edition 2018-09-18 19:06:04 -04:00
Robin Gareus ea8d089e3c Use new externally_connected API 2017-10-30 19:43:32 +01:00
Robin Gareus db674ac8b6 Remove unused per-port buffer offset 2017-10-29 20:04:11 +01:00
Robin Gareus 4f03b7c101 NO-OP: whitespace 2017-10-29 20:04:09 +01:00
Robin Gareus 927788a0b0 Move vari-speed into backend (resample ports)
Previously Ardour used a /local/ per track vari-speed mechanism.
Now that the disk-reader is a latency-compensated processor, the speed
of each disk-reader would need to be maintained locally, offset by each
disk-reader's output latency. Furthermore each disk-reader may
produce a different number of samples, depending on its global alignment.

This commit introduces port-data resampling directly at the engine-level:
Up/down-sample all input ports at the beginning, and down/up-sample output
port-data using the inverse ratio at the end of the session's process
cycle.
The session itself is unaware of the speed-change, and only needs to
handle transport speeds {-1, 0, +1}.

This also allows for aligned cue-monitoring and vari-speed recording,
and also pitch-shifts synthesized MIDI along.
2017-10-29 20:04:00 +01:00
Robin Gareus 71424c9db5 NO-OP: whitespace 2017-09-18 06:47:01 +02:00
Robin Gareus 7235d9751b Add debug-msg for port-handle registration 2017-08-07 23:03:08 +02:00