Commit graph

123 commits

Author SHA1 Message Date
Mads Kiilerich
79e99c12a5 audio_backend: Rename instantiate() parameter arg1 to client_name
This parameter is consistently used to name the audio backend instance
and how it appear as client of the sound server. Just name it
`client_name`, consistent with the name of the jack_client_open
parameter it is passed to .
2024-10-22 01:54:43 +02:00
Mads Kiilerich
710bd07cd4 audio_backend: Rename instantiate() parameter arg2 to session_id
The thing called backend_client_name defaulted to lowercase PROGRAM_NAME
and could be controlled with:

    -c, --name <name>           Use a specific backend client name, default is ardour

This value was *only* used for set_backend arg2 which only is used for
jack, where it was called session_uuid and passed to jack_client_open as
"a SessionID Token this allows the sessionmanager to identify the client
again" because JackSessionID.

It is certainly misleading to call it a uuid. It also doesn't seem
helpful to call it "client name" when the documentation calls it
"session id". And mostly: jack_client_open calls its *first* argument
"client_name" and it comes from argv1.

To clear things up, consistently call it something with "session id".
And it is not helpful to use a generic arg2 naming.
2024-10-22 01:54:43 +02:00
Mads Kiilerich
9c0c4f527b audio_backend: Merge is_realtime() into client_real_time_priority()
The description of is_realtime() did not match its actual use. And
client_real_time_priority() did not have any description. It was
hard to come up with good descriptions of what they actually did.

Most backends returned true from is_realtime(), but every one except
JACK used the default implementation of client_real_time_priority() that
returned 0 ... which is exactly the same as when is_realtime() returns
false. Just merge them and keep it simple.
2024-10-22 01:54:43 +02:00
Mads Kiilerich
a3ac3c7201 audio_backend: Get name of standard device directly, without unnecessary enum StandardDeviceName
The StandardDeviceName enum was misleadingly *not* the name - the name
only came from get_standard_device_name.

Instead, simplify things, and just use two different trivial getters.
2024-10-22 01:54:42 +02:00
Robin Gareus
74c4ca3e52
Reduce reliance on boost - the hard part
the rest from `tools/convert_boost.sh`.

* replace boost::function, boost::bind with std::function and std::bind.

This required some manual fixes, notably std::placeholders,
some static_casts<>, and boost::function::clear -> = {}.
2024-10-19 03:47:21 +02:00
Mads Kiilerich
0d4bce8663
backends: Fix class name in debug and error messages for set_latency_range and get_latency_range traces 2024-10-15 00:41:12 +02:00
Robin Gareus
8115578d4e
Add RT thread priority debugging 2024-10-14 21:49:56 +02:00
Robin Gareus
e8c67408bb
Impose stack limit on backend threads (freewheeling, MIDI poll) 2024-09-28 03:16:42 +02:00
Robin Gareus
ab0d2dce6f
Fix reduced channelcount when restarting engine with different device
1. Start engine with a stereo soundcard (n_inputs was set to 2)
2. Restart engine with multi-channel soundcard, n_inputs remained a 2)
2024-07-10 15:39:01 +02:00
Robin Gareus
d6b14e761b
Remove unused backend channel count config API 2024-07-10 15:39:01 +02:00
Robin Gareus
dacf488c86
Fix callback order of port-dis/connections
Previously the port-engine was a LIFO. Changes were pushed back
and then popped-back. This causes issues when re-connecting
Transport Masters.

The GUI does the following when changing connections:
1. disconnect all
2. connect to new port

which lead to TransportMaster::connection_handler being called
in reverse order: connect, disconnect, and the transport
master was assumed to not be connected.

--

Now connections queue is a FIFO and code was consolidated.

(Note, we cannot use a std::deque because it does not support
memory pre-allocation with ::reserve)
2023-12-02 23:34:58 +01:00
Robin Gareus
00b2f5696c
PortAudio: implement MIDI device config 2023-06-18 02:35:03 +02:00
Robin Gareus
9b797dc4c1
PortAudio: fix latency reporting, disable custom MIDI cfg
This correctly sets audio port I/O latency using the
portaudio API.

Per MIDI device port settings are not completely implemented.
En/disabling MIDI devices or setting custom MIDI port latency
is not functional as-is.
2023-06-17 05:49:11 +02:00
Robin Gareus
e938d4936f
Further speed up Windows freewheel export 2023-06-05 01:42:24 +02:00
Robin Gareus
c24b456211
Windows: unconditionally request high timer resolution
Previously timeBeginPeriod() was only called when MIDI
system was set to WinMME. It was also possible that
it was never unset in case starting the engine failed.

This significantly speeds up freewheel export which uses
Glib::usleep(100) when MIDI is disabled.

see also: https://randomascii.wordpress.com/2020/10/04/windows-timer-resolution-the-great-rule-change/
2023-06-05 00:02:54 +02:00
Robin Gareus
c56313cea0
Fix setting pretty-names when engine is restarted
port-meta-data depends on the audioengine backend/device
settings. Those are only available after the engine is started,
not from within the backend's _start() method.

This is is only relevant for callback based backends.

Backends with a blocking process thread explicitly emit
port-manager callbacks there before entering the main loop.
2023-06-02 00:29:03 +02:00
Paul Davis
a486fba3e9 std::atomic - 2nd batch of changes to convert from glib to std::atomic 2023-03-24 14:19:15 -06:00
Paul Davis
4ba4cd69ff switch from glib atomic to std::atomic (libs edition) 2023-03-24 14:19:15 -06: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
b77eedf53e
Suggest WinMME as default (enable MIDI by default) 2022-07-11 21:45:55 +02:00
Robin Gareus
64f9829b56
AudioBackends: ignore setting latency of invalid port(s) 2022-06-24 19:55:17 +02:00
Robin Gareus
35612d26c6
Unify ::get_buffer, remove debug code 2022-06-18 22:54:09 +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
Paul Davis
a9f285b82b debugging timing stats by showing how max values are computed 2021-06-29 09:46:46 -06:00
Paul Davis
9d88f370ae debug windows RunLoop timing stats 2021-06-29 09:25:38 -06:00
Paul Davis
74538b7114 window compilation fix 2021-06-26 18:58:23 -06:00
Paul Davis
a2974b0c0b portaudio: improved compilation error fix 2021-06-26 12:56:49 -06:00
Paul Davis
8bc4464309 portaudio: compilation error fix 2021-06-26 12:51:54 -06:00
Paul Davis
7e858b9bda portaudio: add standardized DSP statistics to portaudio backend (uncompiled) 2021-06-26 12:32:23 -06:00
Robin Gareus
634d325e5d
Prevent deadlock when disconnecting
The backend holds `_port_callback_mutex` while disconnecting ports.
In some cases disconnecting a port can drop the last reference
resulting in a port-deletion from the connection handler.
This in turn will eventually aquire the `_port_callback_mutex`
and deadlock.

This is now circumvented by using atomic operations instead of
taking a lock to set the `_port_change_flag`.

The flag is also used to trigger a latency update in some cases,
atomic is preferable to taking a lock to set this flag.

--

Full bt: https://paste.debian.net/1184056/
Short:

#1  in pthread_mutex_lock ()
#2  in ARDOUR::PortEngineSharedImpl::port_connect_add_remove_callback()
#3  in ARDOUR::BackendPort::~BackendPort()
#4  in ARDOUR::DummyPort::~DummyPort()
#6  in ARDOUR::DummyAudioPort::~DummyAudioPort()
#7  in boost::checked_delete<ARDOUR::BackendPort>(ARDOUR::BackendPort*)
#12 in boost::shared_ptr<ARDOUR::ProtoPort>::reset()
#13 in ARDOUR::Port::drop()
#14 in ARDOUR::Port::~Port()
#15 in ARDOUR::AudioPort::~AudioPort()
#17 in ARDOUR::AudioEngine::add_pending_port_deletion(ARDOUR::Port*)
#20 in boost::detail::sp_counted_base::release()
#37 in ARDOUR::PortManager::connect_callback() at libs/ardour/port_manager.cc:788
#38 in ARDOUR::DummyAudioBackend::main_process_thread() at libs/backends/dummy/dummy_audiobackend.cc:1018
2021-02-04 21:06:20 +01:00
Robin Gareus
21e66216be
Separate user-set pretty-names from hardware I/O names
This allow to restore original engine port-names as set
by the backend. ALSA MIDI, CoreAudio, CoreMIDI and PortAudio
drivers can provide human readable physical port names for
some devices.
2021-01-18 03:18:20 +01:00
Robin Gareus
a80064981e
NO-OP: Consolidate PortConnect code into shared parent class 2020-09-05 23:05:57 +02:00
Robin Gareus
09aa0a3d1a
Consolidate code using pthread_attr_setstacksize
This also adds some stack constraint to rt and fallback threads
that didn't have those before (ALSA MIDI for example)
2020-06-06 18:35:44 +02:00
Robin Gareus
3d166c7789
Consolidate stack-size and priority of rt-threads 2020-04-23 01:28:58 +02:00
Paul Davis
78a66b7180 improved port cleanup as backend is destroyed 2020-04-07 23:26:51 -06:00
Paul Davis
32734ce53c fix portaudio backend to use shared_ptr 2020-04-07 16:00:22 -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
Paul Davis
6a6b3f2703 fix another iterator type 2020-04-02 19:45:31 -06:00
Paul Davis
cb4997f4a4 fix iterator type 2020-04-02 19:45:31 -06:00
Paul Davis
af69ac1285 use clear_ports() 2020-04-02 19:45:31 -06:00
Paul Davis
7fc5a6c971 initial try (not compiled) of PortAudio backend using PortEngineSharedImpl 2020-04-02 19:45:31 -06:00
Robin Gareus
a8ff35accb
Reset DSP load on backend re-start and after freewheeling 2020-03-30 16:58:55 +02:00
Robin Gareus
47a62b2850
Update backend GPL boilerplate and (C) from git log 2019-08-03 15:53:16 +02:00
Robin Gareus
076e9fddd4
Remove ambiguous API implementation
* PortEngine::available() implementation
* AudioEngine::connected() wrapper

Eventually we may re-introduce PortEngine::available along
with a libardour internal port-engine.
2018-11-28 15:32:40 +01:00
Robin Gareus
070f370e40 Fix copy/edit in e047b01aa2 2018-10-18 15:07:45 +02:00
Paul Davis
e047b01aa2 add new API for retrieving port flags from backend 2018-10-17 14:11:37 -04:00
Robin Gareus
e39a8b90d9 amend ab3889ff: portaudio backend uses a vector for connections 2017-09-23 01:06:10 +02:00
Robin Gareus
ab3889fff8 Propagate Latency to backend/system ports
Set accumulated capture-latency for physical-outputs
and accumulated playback-latency for physical-inputs
after Ardour is done setting all non-physical port latencies.

This will be needed for latency-compensation of the complete graph.
2017-09-23 00:34:01 +02:00
Paul Davis
30b087ab3d globally change all use of "frame" to refer to audio into "sample".
Generated by tools/f2s. Some hand-editing will be required in a few places to fix up comments related to timecode
and video in order to keep the legible
2017-09-18 12:39:17 -04:00
Robin Gareus
467c801ce8 Abstract definition of rt-scheduler policy
pthread-w32 does not support pthread_setschedparam() with
SCHED_FIFO and bails out. While pthread_create() simply ignores the policy
and sets the priority regadless.

This only affects ctrl-surface event-loops & AutomationWatch on Windows.
2017-08-29 20:35:36 +02:00