Commit Graph

933 Commits

Author SHA1 Message Date
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
Paul Davis 0eed821eb9 JACK: do not set the thread-init callback
Because we use the non-callback API, we can call our thread init callback
ourselves from ::process_thread(). In addition, the init_callback in JACK is
used by every thread JACK creates, including the messagebuffer thread, and this
confuses things from an Ardour POV where the callback was intended just for
realtime threads.
2023-04-21 12:16:37 -06:00
Robin Gareus 295dbd8e1e
Make RCU reader return a const pointer (omnibus commit) 2023-04-08 00:15: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
Paul Davis 39ed528e25 std-ize: convert all boost shared/weak ptr includes to <memory>
Also fix stdint.h -> cstdint and alphabetically order std includes
2023-03-24 14:19:15 -06:00
Robin Gareus 475063c24d
ALSA: update endianess conversion functions
This follows upstream zita-alsa-pcmi-0.6.1
2022-12-27 13:32:31 +01:00
Robin Gareus a7d2718aa4
ALSA: use dedicated device reservation for probing
It can happen that the main AlsaAudioBackend::_device_reservation
is still busy while I/O devices are set. In this case a
dedicated AlsaDeviceReservation needs to be used which can fail
silently.

A common example is disconnecting a USB device while it is in
use. The Halted signal can show the session dialog, which calls
set_input_device_name before the device reservation of the
unplugged device terminated.
2022-11-29 17:34:45 +01:00
Robin Gareus 3f4feb6cc8
ALSA: fix autostart when using different I/O devices
ALSA backend modified the internal state when different devices
were used, re-assigning one (usually input-device) to "None"
when it's resampled. This lead to EngineHints not matching the
EngineState, and autostart was disabled, and a dialog
"Engine I/O device has changed since you last opened this session."
2022-11-29 06:39:50 +01:00
Mads Kiilerich 4958c0d666
PulseAudio: fix error message 2022-11-04 13:44:55 +01:00
Mads Kiilerich c2db9b4606
PulseAudio: just start stream uncorked
There was no reason to cork it when it was uncorked right after.

Playback will start when the buffer is full anyway.
2022-11-04 13:44:55 +01:00
Mads Kiilerich 00d3ce6b62
PulseAudio: remove commented out code 2022-11-04 13:44:55 +01:00
Mads Kiilerich 40f9e0c6a6
PulseAudio: use explicit defaults for tlength and prebuf
These might be the values that PA would have chosen anyway, but make it
clear that Ardour is in control ... and will let the user control
"everything" with the buffer size.
2022-11-04 13:44:55 +01:00
Mads Kiilerich 584ee51ca8
PulseAudio: set buffer attributes where they are used
Just moving code.
2022-11-04 13:44:55 +01:00
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
Mads Kiilerich ef5b29c6dd
PulseAudio: group operations and their verification together
Improves readability a bit. IMO.
2022-11-02 02:24:35 +01:00
Mads Kiilerich b046ffe395
PulseAudio: drop idempotent dynamic cast 2022-11-02 02:24:35 +01:00
Mads Kiilerich 5bb7336c79
PulseAudio: consistent use of _buffer
For consistency and readability, avoid using high level getter in low
level code.
2022-11-02 02:24:35 +01:00
Mads Kiilerich 51501e5532
PulseAudio: don't set _run = false when stop() already did it 2022-11-02 02:24:35 +01:00
Mads Kiilerich ba5ca2de05
PulseAudio: always log error reason in error handling
It adds some new strings to translate. These strings might be so rare
and technical that it is a bit pointless to translate them. But let's
stay consistent...
2022-11-02 02:24:35 +01:00
Mads Kiilerich 3fbbef3038
PulseAudio: fix "already active" message emitted when not active
Apparently just a missing fixup after copy-paste.
2022-11-02 02:24:34 +01:00
Mads Kiilerich 2666dfe900
PulseAudio: add missing return in error handling
Don't try to continue if the initial uncorking fails.
2022-11-02 02:24:34 +01:00
Mads Kiilerich 06b3d5ba33
PulseAudio: spin waiting for enough capacity to write
pa_threaded_mainloop_wait might wake up for several reasons. And there
is no point (but possibly harm) in moving on before we have verified
that PA actually is ready to receive our write without overflow.
2022-11-02 02:24:34 +01:00
Mads Kiilerich 27a2bf1f59
PulseAudio: clean up freewheeling transitions
ae3c8b19c6 and 03a17df68c reworked the transitions to and from
freewheeling. Some of it seems to have been experiments that tried
several things out, and generally it seems to have worked. It left some
commented out code. Clean that up.
2022-11-02 02:24:34 +01:00
Mads Kiilerich 04c24be2db
PulseAudio: don't drain the stream right after initial uncorking
The draining was introduced in ae3c8b19c6, apparently as an experiment
doing several changes. But the drain is outside the loop where
freewheeling changes, so the fix must have worked for other reasons.

There doesn't seem to be any benefit from draining at that point. The
stream is already empty. If not, we could have flushed it.

Draining right after uncorking will conceptualy create an intentional
underflow, even though it isn't reported as such. PipeWire seems to
(something like 6-12 months ago) have regressed in handling of that grey
area, causing that *underflow* to cause a request for too much data, and
thus causing constant *overflows* and unusable playback.

This change makes PulseAudio playback work for me again.
2022-11-02 02:24:34 +01:00
Paul Davis 1eaaf4303b jack backend: catch some possible errors in ::get_port_name() 2022-10-29 09:37:17 -06:00
+merlan #flirora 79f55742d6
JACKAudioBackend::join_process_threads: Don’t pass NULL for jack_client_stop_thread
This is needed for PipeWire’s JACK frontend, which implements this
function and expects the first argument to be non-null.
2022-10-24 04:45:08 +02:00
Robin Gareus 7e5fe695d0 Increase coreMIDI robustness, do not drop late events
see also https://discourse.ardour.org/t/ardour-not-getting-all-messages-from-midi-keyboard/107618/13
2022-09-24 02:29:50 +02:00
Robin Gareus 9b65be0e17
Add debug information for coreMIDI events 2022-09-22 00:42:56 +02:00
Robin Gareus 46deb15d12
ALSA: request device to query its settings
Querying available buffersizes and sample-rates requires access
to the device. Almost all ALSA devices are limited to
a single user-space application so we unconditionally try
to request access to the device.
2022-09-12 16:34:25 +02:00
Robin Gareus 48dbd5801a
Coreaudio: enable MIDI by default 2022-07-27 15:31:20 +02:00
Robin Gareus b77eedf53e
Suggest WinMME as default (enable MIDI by default) 2022-07-11 21:45:55 +02:00
Robin Gareus fe6aa0610c
ALSA: suggest ALSA Sequencer by default 2022-07-11 21:45:54 +02:00
Robin Gareus 13de664ae6
Provide jack2 compatible implementation for jack1
jack1 (which is Linux only) does not have a jack_client_stop_thread
API, and expects the application to call pthread_join().

This fixes an issue when the application is compiled using jack2 headers
but the application later runs using jack1's library.
2022-06-30 17:19:57 +02:00
Robin Gareus 64f9829b56
AudioBackends: ignore setting latency of invalid port(s) 2022-06-24 19:55:17 +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 99e785541a
Coreaudio/M1: prefer device IOThread Workgroup 2022-06-03 22:50:13 +02:00
Robin Gareus fa8f75c145
Fix yet another oversight when coding blindly in 6a513a11f 2022-06-03 07:29:23 +02:00
Robin Gareus 5417ddd792
Fix typo in 6a513a11f 2022-06-03 07:24:42 +02:00
Robin Gareus 58979af4f2
Coreaudio: update workgroup query 2022-06-03 06:42:42 +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
Robin Gareus 96c138c985
ALSA: prevent excessive slave-device latency updates on underrun 2022-05-04 05:57:52 +02:00
Mads Kiilerich 5b7431f243 wscript: drop unnecessary trailing ";" 2022-04-09 12:16:41 +02:00
Mads Kiilerich bac32a8c2d wscript: consistently use 4 spaces for indentation 2022-04-09 12:16:40 +02:00