Commit Graph

962 Commits

Author SHA1 Message Date
Robin Gareus e2cdb3f5d8
Dummy Backend: allow testing with some prime buffersizes 2024-02-12 14:07:59 +01: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
Mads Kiilerich 2bb311f99b wscript: don't add pointless -DHAVE_X for each mandatory subdir
The sub_config_and_use function recursed, but it also invoked
autowaf.set_local_lib , which however didn't do anything useful. The
HAVE_ defines are not used anywhere, and the AUTOWAF_LOCAL defines are
only used in autowaf.use_lib, which however isn't used anywhere.

Dropping these defines simplify the build environment and makes the
compiler command line half as long and thus makes debugging much more
manageable.
2023-10-15 10:47:16 -06:00
Mads Kiilerich 88cecdfaef wscript: drop repeated autowaf.set_options - it is enough to set at top level 2023-10-15 10:47:16 -06:00
Mads Kiilerich d220f477ed wscript: drop unused "mandatory variables" 'top' and 'out' in libs
Variables by these names are only used from the local wscript and when
running "waf configure", which already for other reasons only can run at
the top-level.

These variables are thus not mandatory and not used.
2023-09-17 07:34:55 -06:00
Mads Kiilerich 7737c17d52 wscript: drop unused imports, scripted
Done with ad hoc scripting hacks processing unused imports found by pyflakes:

for f in $( find * -name wscript ); do echo; pyflakes $f; done | grep 'waflib.Logs.* but unused' | cut -d: -f1 | while read f; do sed -i 's/^import waflib.Logs as Logs,/import/g' $f; done
for f in $( find * -name wscript ); do echo; pyflakes $f; done | grep 'waflib.Options.* but unused' | cut -d: -f1 | while read f; do sed -i 's/import waflib.Options as Options, /import /g' $f; done
for f in $( find * -name wscript ); do echo; pyflakes $f; done | grep 'waflib.Options.* but unused' | cut -d: -f1 | while read f; do sed -i 's/^from waflib import Options,/from waflib import/g' $f; done
for f in $( find * -name wscript ); do echo; pyflakes $f; done | grep ' imported but unused$' | sed "s/^\([^:]*\):[0-9]*:[0-9]* '\(.*\)'.*/\1 \2/g" | while read f lib; do sed -i "/^import $lib$/d" $f; done
for f in $( find * -name wscript ); do echo; pyflakes $f; done | grep 'waflib.Options.* but unused' | cut -d: -f1 | while read f; do sed -i '/from waflib import Options$/d' $f; done
for f in $( find * -name wscript ); do echo; pyflakes $f; done | grep 'waflib.TaskGen.* but unused' | cut -d: -f1 | while read f; do sed -i '/from waflib import TaskGen$/d' $f; done
for f in $( find * -name wscript ); do echo; pyflakes $f; done | grep 'waflib.Task.Task.* but unused' | cut -d: -f1 | while read f; do sed -i '/^from waflib.Task import Task$/d' $f; done
for f in $( find * -name wscript ); do echo; pyflakes $f; done | grep 'waflib.Tools.winres.* but unused' | cut -d: -f1 | while read f; do sed -i '/^from waflib.Tools import winres$/d' $f; done
for f in $( find * -name wscript ); do echo; pyflakes $f; done | grep 'waflib.Utils.* but unused' | cut -d: -f1 | while read f; do sed -i '/^import waflib.Utils as Utils$/d' $f; done
2023-09-17 07:34:55 -06:00
John Emmas 56772b8156 Revert an unintended change from #eff61bde325b 2023-09-14 16:54:15 +01:00
Paul Davis eff61bde32 JACK: accomodate MSVC in DEBUG_TRACE stmts involving pthread_self 2023-09-14 06:59:29 -06:00
Paul Davis 2fa6500ec5 NOOP: fix indentation 2023-09-13 10:23:58 -06:00
Paul Davis 3c857a78c6 JACK backend: serialize all jack server calls with a mutex
As was noted in 88ee3af3ea it is unsafe/undefined behavior if two threads
sleep on the JACK request file descriptor, since there is no way to control
which one will wake and process the request. Since each thread may have
sent a different request, this can lead to a thread misinterpreting the
response because it is reading the wrong response.

This may (or may not) solve some subtle problems with JACK, but was
revealed by having a control surface (LaunchPad Pro) that registers
three ports from the butler thread at about the same as the GUI
thread is registering the auditioner. One thread read the wrong
response, and because of some slightly weird code/design, it attempts
to rename the port from within the response handler, which in JACK1
leads to deadlock (and later, zombification).
2023-09-13 09:20:41 -06:00
Paul Davis 88ee3af3ea JACK backend: add a mutex to serialize per-thread port register requests to server
Without this, two threads can both sleep on the same communication channel, and the wake order
is non-determinate, so the wrong thread may process the response to the other thread's request.
2023-09-12 22:41:26 -06:00
Robin Gareus efed61af44
Amend d899441df1, fix duplicate device map entries 2023-07-03 19:57:55 +02: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 bef4596dd1
NO-OP: whitespace 2023-06-29 00:32:46 +02:00
Robin Gareus 651dcbc96e
CoreAudio: Remove unused API 2023-06-29 00:32:46 +02:00
Robin Gareus 9a010404d1
CoreMIDI: Remove unused API 2023-06-29 00:32:43 +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 cd4fff863a
Dummy backend: add realtime option
On windows this is still limited by the timer resolution, but
it's a start. This is mainly intended to be used with NDI or
other external sources without actual audio hardware.
2023-06-20 01:36:44 +02: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 639696c1a8
ALSA: fix adding n_period playback latency
Use playback port, not capture port.
2023-06-17 00:53:22 +02:00
Robin Gareus 7aad0bbe15
CoreMIDI: use dedicated packet buffer on stack 2023-06-13 16:50:53 +02:00
Paul Davis 12c3daa46b JACK: fix reported tempo & meter when functioning as JACK timebase master
TempoMap::metric_at() has a superclock_t variant that was being called
with a samplepos_t value. Full check (and removal, hopefully) coming up.
2023-06-12 12:10:26 -06: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 0006f4d8cd
Dummy: add MMC test sequence 2023-06-03 19:10:32 +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 edcf850aaf
Fix Wformat 2023-05-19 06:16:49 +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
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