Commit graph

120 commits

Author SHA1 Message Date
kiilerix
13305304af
Merge 79e99c12a5 into 152e0c2beb 2025-11-28 18:12:52 -08:00
Robin Gareus
f6a2ee0103
Prefer std::regex, and modern C++ string search 2025-11-11 19:04:16 +01:00
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
e6bed9330f
CoreMIDI: fix capture/playback alignment
MIDI playback used samples instead of usec.
MIDI capture used time-stamp from previous cycle.
buffer-size changes were not applied to MIDI port latency
2023-06-29 00:32:46 +02:00
Robin Gareus
a10e3edb53
Remove unused backend API 2023-06-21 23:59:49 +02:00
Robin Gareus
341cd455d8
CoreAudio: unconditionally apply device latency 2023-06-21 23:54:55 +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
Robin Gareus
a7ca4cf8a1 CoreAudio: subscribe to device-alive property
This notifies the user about device disconnect and properly
shuts down the backend.
2023-04-22 19:36:37 +02:00
Robin Gareus
d9c35199cc CoreAudio: Update latency when buffesize changes 2023-04-04 19:26:17 +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
48dbd5801a
Coreaudio: enable MIDI by default 2022-07-27 15:31:20 +02:00
Robin Gareus
fe0e997335
Backend: prefer debug_msg over PBD::Transmitter in threads
PBD::Transmitter is neither thread-safe nor rt-safe. This likely
fixes a crash on macOS when process-threads are started.
Many threads simultaneously enter coreaudio_process_thread() and
log a message calling `PBD::info << .. << endmsg` simultaneously.
2022-06-24 19:27:57 +02:00
Robin Gareus
35612d26c6
Unify ::get_buffer, remove debug code 2022-06-18 22:54:09 +02:00
Robin Gareus
fa8f75c145
Fix yet another oversight when coding blindly in 6a513a11f 2022-06-03 07:29:23 +02:00
Robin Gareus
6a513a11fa
Coreaudio: set real-time constraint before joining the workgroup
The worker thread needs to have a real-time constraint set,
before it cab be joined to the workgroup.
2022-06-03 06:42:38 +02:00
Robin Gareus
74ee7ee091
Add parallel realtime threads to CoreAudio workgroup
This API is only available since BigSur (11.0), see also
https://developer.apple.com/documentation/audiotoolbox/workgroup_management/adding_parallel_real-time_threads_to_audio_workgroups?language=objc
2022-06-03 04:56:28 +02:00
Robin Gareus
88e9fc3e22
Remove unneccesary include (now handled by libpbd) 2022-06-03 04:52:38 +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
c7bed1320e adding DSP stats to coreaudio backend (uncompiled) 2021-06-26 11:25:07 -06:00
Robin Gareus
438b1e5eab
Cont'd work to improve macOS rt priority 2021-05-02 20:24:10 +02: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
5e76d63c06
Resolve some Xcode12 C++11, sigc++ issues 2020-12-12 04:46:22 +01:00
Robin Gareus
802ddf344a
Remove unused mutex (amend a80064981e) 2020-09-06 05:43:03 +02: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
1e996ca45f add port connect/add/remove callbacks to CoreAudio backend 2020-04-10 10:01:04 -06:00
Paul Davis
78a66b7180 improved port cleanup as backend is destroyed 2020-04-07 23:26:51 -06:00
Paul Davis
ff41232d16 fix CoreAudio backend to use shared_ptr 2020-04-07 13:52:35 -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
30766c75e8 buildable version of CoreAudio backend using PortEngineSharedImpl 2020-04-02 19:45:31 -06:00
Paul Davis
a31d3689bf tentative changes to extend port engine shared impl to coreaudio 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
c365c6cdb2
Set thread-names (libs) 2020-03-29 14:56:22 +02:00
Robin Gareus
140a3f4a10 Fix Coreaudio buffersize changes 2020-03-06 05:52:55 +01:00
Robin Gareus
a9c75f9760
Fix CoreAudio systemic latency, implement hw latency report 2020-02-24 04:24:50 +01:00
Robin Gareus
47a62b2850
Update backend GPL boilerplate and (C) from git log 2019-08-03 15:53:16 +02:00