Commit Graph

134 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
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 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
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 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 a393f75694
Use shared port engine MIDI event compare operator 2021-11-30 19:41:39 +01: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 b46a7d43c2
Dummy Backend: add a MIDI Clock generator 2020-05-27 23:40:06 +02:00
Robin Gareus 7c15ad099f
Dummy Backend: add a MTC generator 2020-05-12 01:49:41 +02:00
Robin Gareus 3d166c7789
Consolidate stack-size and priority of rt-threads 2020-04-23 01:28:58 +02:00
Paul Davis f32245c156 add required ::clear_ports() call to Dummy backend destructor 2020-04-08 14:55:31 -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 04551c39f6 use PortEngineSharedImpl with DummyAudioBackend 2020-04-02 19:45:31 -06:00
Robin Gareus c87bec07cd
Fix thinko in eee01188 (engine pulse spacing) 2020-01-12 00:16:19 +01:00
Robin Gareus eee01188b4
Dummy: Engine-Pulse audio/midi generators
This produces synchronous events on Audio and MIDI ports.
One rvent per second, exactly at every second since engine-start.

MIDI: C-4 Note-on/off (1 sample long)
Audio: +1/-1 transition:
       +1 in sync with Note-on,
       -1 in sync with Note-off
2020-01-06 22:43:30 +01:00
Robin Gareus 47a62b2850
Update backend GPL boilerplate and (C) from git log 2019-08-03 15:53:16 +02:00
Robin Gareus ce961d73f3
Use unique midi-port names for Ardour's Dummy backend 2019-03-06 23:48:07 +01: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 4e4c6e7d1e Fix an edge-case in Dummy backend's random generator
INT_MAX == 2^31 is not a valid random seed for this LCG.
2018-10-22 15:46:59 +02:00
Paul Davis e047b01aa2 add new API for retrieving port flags from backend 2018-10-17 14:11:37 -04:00
Robin Gareus 7512692e79 Fix initial cycle noise with dummy-loopback 2017-10-28 15:45:08 +02:00
Robin Gareus 7e2c002ef6 Propagate Latency to backend/system ports (Dummy backend)
amend ab3889ff (which implements this for other backends)
2017-09-28 13:14:11 +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 7258c6334d Namespace PBD::RingBuffer
class RingBuffer<> is a very generic name and should not pollute the
global namespace.
2017-09-16 16:37:29 +02:00
John Emmas 14fcf86f03 MSVC uses a slightly smaller value for HUGE 2017-09-11 19:25:13 +01:00
Robin Gareus 2961db3b6f Use literal for compatibility 2017-08-23 12:43:48 +02:00
Robin Gareus 2b7c585dba Update backend API: read-only MIDI input buffers 2017-08-05 15:36:36 +02:00
Robin Gareus 4ec72b5c76 DummyBackend: allow changing SPP 2017-08-04 03:53:51 +02:00
Robin Gareus 660096b037 Fix typo 2017-07-31 19:54:23 +02:00
John Emmas 7f03c9a664 Fix an ambiguous call to 'floor()'
MSVC complains, so let's specify which override we want.
2017-07-29 10:44:00 +01:00
Robin Gareus 7b7cc9ea6d Add a LTC generator to the dummy backend 2017-07-28 17:47:36 +02:00
Robin Gareus e511985ad9 Report Dummy as not available if not running
This fixes an issue with port-connections being polled from the backend
even when it's not running.
2017-06-25 20:53:47 +02:00
Robin Gareus f9db9bf5fd Retain order of concurrent MIDI events
This fixes an issue with FaderPort8 (and maybe other surfaces or synths).
2017-04-08 23:43:50 +02:00
Robin Gareus a76607486c kilo is a lower-case 'k' 2016-07-24 16:54:08 +02:00
Paul Davis cf52d6e4b4 enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h 2016-07-14 14:45:23 -04:00
Robin Gareus ac923be7af fix port-sort order for good.
TODO find out how to make std::set::find() work with custom sort order,
as std::find may only be O(N) and not O(log (N)).
2016-07-08 21:37:42 +02:00
Robin Gareus afc1186759 NO-OP indent 2016-05-22 19:36:54 +02:00
John Emmas 39ba60aaef Make sure MSVC knows which version of 'floor()' we want 2016-05-22 15:53:16 +01:00
Robin Gareus 9ad096b611 Dummy Backend evolution
- pretty port-names for Dummy generators: show frequency
- add 1/3 Octave spaced sine-wave generator
2016-05-21 22:38:39 +02:00
John Emmas dc1a2fbca7 MSVC won't compile 'const float _demolition[]' because it uses 'divide by zero' while initializing
Hopefully we can use INFINITY and NAN for the relevant initializers ?
2016-05-03 17:30:58 +01:00
Robin Gareus 69f99ee184 I wanna be nasty, I wanna be cruel,..
Somme disastrous signal generators for QA.
2016-04-29 16:10:09 +02:00
John Emmas 93eac8b068 Use 'const_iterator' to prevent MSVC from complaining 2016-04-26 14:58:16 +01:00
Robin Gareus 2169de3975 keep portmap & portindex in sync when renaming ports
Fixes crash on session re-load (introduced in 800c8182 and fde99e68)
2016-04-26 02:26:20 +02:00