Commit graph

28 commits

Author SHA1 Message Date
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
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
Robin Gareus
38a4bb6736
Fix prev commit (properly stop pulse) 2021-07-21 05:56:42 +02:00
Robin Gareus
03a17df68c
Pulseaudio: tweak freewheel recovery
Always cork stream before calling pa_stream_flush.
2021-07-21 05:03:54 +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
80e3c191e4
Pulseaudio: allow steam being suspended during export
When exporting long sessions with freewheeling, pulseaudio
may meanwhile suspend the corked audio device. The "FAIL_ON_SUSPEND"
option then prevents ardour to uncork it after export, and the
audio-backend is halted.
2020-11-22 21:41:47 +01:00
Robin Gareus
81862f8c30
Allow to move pulse stream #8467
This potentially breaks various assumptions (e.g. no resampling,
fixed buffersize) when the stream is moved to a different device.
Then again it's pulseaudio, which is unsuitable for pro-audio to
begin with.
2020-11-11 15:59:26 +01:00
Robin Gareus
cf0904f752
Handle vfork/exec failure
Don't call atexit, exit without cleanup.
2020-10-31 22:33:10 +01:00
Robin Gareus
a9bd7b2848
Remove unused compile-time option to not use vfork 2020-10-31 22:30:45 +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
ae3c8b19c6
Tweak PulseAudio re-initialization
This fixes an issue with pulse disconnecting after freewheeling,
and possibly also address #8193
2020-06-05 04:24:09 +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
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
e5507f7072 use PortEngineSharedImpl with PulseAudio backend 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
f866ed6305
Remove duplicate calls 2020-03-30 15:20:54 +02:00
Robin Gareus
45cf29b7c5
Use preferred pa_context_new_with_proplist API 2019-09-01 19:01:18 +02:00
Robin Gareus
47a62b2850
Update backend GPL boilerplate and (C) from git log 2019-08-03 15:53:16 +02:00
Robin Gareus
8a969b56c9
PA-backend: Flush buffer and wake up main thread at stop 2019-07-26 21:38:40 +02:00
Robin Gareus
b759fb883e
Launch pavucontrol as PA's control app 2019-07-26 04:43:56 +02:00
Robin Gareus
d7454714ab
Fix PA: unlock mainloop on abort 2019-07-25 21:24:36 +02:00
Robin Gareus
384c97e12d
Puls der Zeit
Prototype a basic stereo-playback only pulseaudio backend.
2019-07-25 17:49:42 +02:00