Wim Taymans
955dde5272
alsa-plugin: use hw_avail in _delay for playback
...
for playback streams we want to include the hw_avail, which is the amount of
data that the hardware can read or the amount of data the application has
written.
This is in contrast to using _avail for the capture stream, which is
what the application can read. hw_avail for a capture stream is how many
samples the hardware can write or the amount of free space.
See #1697
2021-11-24 13:12:23 +01:00
Wim Taymans
743cced63e
alsa-plugin: improve debug
2021-11-24 12:40:02 +01:00
Wim Taymans
301e729864
alsa-plugin: fix delay reporting
...
The delay should be calculated based on the amount of samples available
to the application, not the hardware.
This overreported the delay.
See #1697
2021-11-24 12:24:29 +01:00
Wim Taymans
d8e24fca1c
alsa-plugin: don't rate match for capture streams
...
For capture streams we can simple copy the complete pipewire buffer into
the alsa pcm ringbuffer to make it available for the application.
2021-11-24 12:24:29 +01:00
Wim Taymans
33f087d4db
alsa-plugin: don't clamp elapsed time to stream delay
...
There is no reason to limit the elapsed time to the stream delay, it is
possible that it is larger and then it will be clamped later.
2021-11-24 12:24:29 +01:00
Wim Taymans
6f0c5b6428
alsa-plugin: improve debug
2021-11-24 12:24:29 +01:00
Wim Taymans
25ddf0e3cf
alsa-plugin: fix a compiler warnings
2021-11-02 17:18:58 +01:00
Martin Geier
1b96142903
alsa: do not ignore rate change when stream is already created
...
gstreamer alsasink can change sample while stream is already created.
In that case, gstreamer calls snd_pcm_ioplug_callback_t::stop,
snd_pcm_ioplug_callback_t::hw_params and snd_pcm_ioplug_callback_t::prepare
Add new flag to the snd_pcm_pipewire_t that is set every time
snd_pcm_pipewire_hw_params is called to prevent using stream with old
sample rate
Signed-off-by: Martin Geier <martin.geier@streamunlimited.com>
2021-11-02 15:37:07 +00:00
Martin Geier
a7d238ed59
alsa: increase precision of delay function
...
pw->time.delay is delay in number of frames in pw->time.rate domain,
however snd_pcm_pipewire_delay function is suppose to return number of
frames in io->rate domain. Convert pw->time.delay to io->rate domain to
increase precision when the io->rate is not equal to the pw->time.rate
snd_pcm_pipewire_delay should return how many frames are queued in
pipewire, pw_stream_get_time returns numbers of the queued frames before
snd_pcm_pipewire_process is called, however this function inserts (or
removes) some frames from pipewire. Therefore newly inserted (removed)
frames should be added to pw->time.delay to increase precision.
Signed-off-by: Martin Geier <martin.geier@streamunlimited.com>
2021-11-02 15:37:07 +00:00
Wim Taymans
6ebd589659
alsa-plugin: _prepare will clear the draining state
...
Leave the draining state when _prepare is done.
See #1467
2021-11-02 10:17:31 +01:00
Philippe Normand
cff127a138
pipewire-alsa: Fix build warning
...
`pos < 0` always evaluates to false, so remove this condition.
2021-10-25 07:26:15 +00:00
Wim Taymans
f562b16706
alsa-plugin: use log topics
2021-10-03 08:17:43 +02:00
Jonas Holmberg
61a2577941
pipewire-alsa: fix a memory leak
...
Free node_name.
2021-09-27 11:05:34 +02:00
Wim Taymans
423e8b2f03
Revert "pipewire-alsa: Make it MT safe"
...
This reverts commit f22dd9d781 .
Obsolete now that pw_init and factory loading/unloading has been
made thread safe.
2021-09-21 12:35:03 +02:00
Wim Taymans
f6f10669a0
alsa: destroy stream first and then context
...
This makes things more deterministic.
2021-09-15 20:57:10 +02:00
Jonas Holmberg
f22dd9d781
pipewire-alsa: Make it MT safe
...
Make pipewire-alsa MT safe so that multi threaded programs can use it
without any extra locks.
2021-09-08 16:36:58 +02:00
Wim Taymans
7846687df8
alsa: suggest rate to graph with node.rate
2021-08-18 09:56:20 +02:00
Wim Taymans
780f2d645d
alsa: enable client-rt for alsa clients
...
So that the pipewire thread is running with RT priority.
2021-08-09 15:28:00 +02:00
George Kiagiadakis
5ee9133b60
alsa plugin: allow specifying a media.role on the virtual device name
...
So that we can do:
aplay -D pipewire:ROLE=Music music.wav
aplay -D pipewire:ROLE=Notification notice.wav
2021-06-22 14:48:31 +00:00
Peter Hutterer
0054319d88
meson.build: add -D_GNU_SOURCE to the project arguments
...
This appends it to every compilation command so we can get rid of the c_args
for (almost all) executables.
2021-06-09 07:47:51 +00:00
Peter Hutterer
e0471c6757
pipewire: allow NULL pointers in pw_properties_free()
...
Just like the real free() we should just ignore a NULL pointer, makes the
caller code easier for those instances where properties are optional.
Patch generated with concinelle with a few manual fixes.
2021-06-02 10:56:46 +00:00
Wim Taymans
5a186ece01
alsa: handle plugin errors better
...
When the plugins can't be loaded, we fail to make a main_loop.
Handle this case instead of segfaulting.
See #1239
2021-05-28 11:38:02 +02:00
Peter Hutterer
f3f915e897
pipewire-alsa: fix scan-build errors for unused variables
...
All cases of value stored but never read
2021-05-26 07:51:27 +00:00
Peter Hutterer
7697ed0757
treewide: replace strcmp() == 0 with spa_streq()
...
This change is only done in source files for now, header files will be done
separately.
2021-05-18 22:10:27 +10:00
Wim Taymans
0999f3cf93
alsa-plugin: handle context create error
2021-05-10 13:28:36 +02:00
Peter Hutterer
2405f0942b
spa/buffer: rename SPA_MEMBER to SPA_PTROFF
...
SPA_MEMBER is misleading, all we're doing here is pointer+offset and a
type-casting the result. Rename to SPA_PTROFF which is more expressive (and
has the same number of characters so we don't need to re-indent).
2021-05-06 09:39:39 +00:00
Wim Taymans
184bdbeb4c
alsa-plugin: Implement query_chmaps again
...
Return a list of our supported channel positions.
Fixes #825
2021-03-04 11:56:28 +01:00
Jonas Holmberg
29be757598
pipewire-alsa: fix drain for capture
...
Since pw_stream doesn't call the drained callback after flush for
capture it has to be called explicitly from process.
2021-03-03 19:00:13 +00:00
Wim Taymans
0aadc0450d
alsa: implement poll_descriptors
...
In there we can evaluate the poll fd and make sure it blocks or not
in the following poll based on the buffer filled levels. Some API
is very sensitive about this, it seems.
Fixes #433
2021-03-02 15:03:27 +01:00
Wim Taymans
8386ddff78
alsa-plugin: Fix default channel layout
...
We need to use the default channel layout that alsa clients expect.
Remove query chmap, nobody uses that, we need to use the alsa default
channel map.
Implement set_chmap in case anybody wants to set a custom map.
2021-02-25 17:42:32 +01:00
Wim Taymans
555d5db384
alsa: make sure we are started when draining
...
We need to be started before waiting for drain.
Fixes #787
2021-02-25 12:14:42 +01:00
Wim Taymans
b9241b1d73
alsa: set application.name
2021-02-19 10:06:40 +01:00
Wim Taymans
7053936ffd
don't attempt to connect to empty remote name
...
Fixes jconvolver startup.
See #744
2021-02-18 10:22:39 +01:00
Wim Taymans
972e740519
Don't advertize formats we don't yet support
...
We don't handle the reverse endian formats yet so make sure we
don't advertize them.
2021-02-05 12:12:44 +01:00
Wim Taymans
32a3913933
alsa-plugin: use MIN_BUFFERS for max as well
...
To get a more reasonable max
2021-02-04 17:15:46 +01:00
thedannysmith
5e9246e1f7
alsa-plugin: change hw-constrainy buffer-size
2021-02-04 17:14:19 +01:00
Wim Taymans
675a12ef33
alsa: clamp elapsed time to delay
...
If the elapsed time is larger than the delay, we are dealing with
an older timestamp.
Fixes #597
2021-01-20 11:54:19 +01:00
Wim Taymans
fd520c4b39
alsa-plugin: set buffer size correctly
...
Our output buffer size is always what is needed to produce one
period of samples. We use nframes from the hardware and the rest
we fill with silence.
2021-01-18 10:03:19 +01:00
Wim Taymans
d2aee61880
alsa: don't write more than wat is requested
2021-01-17 17:20:59 +01:00
Wim Taymans
b4e3d546e0
alsa: fill frames with silence when underrun
...
Keep track of how many samples we need to produce. If we don't have
enough samples in the ringbuffer, fill the rest with silence.
See #564
2021-01-15 18:34:38 +01:00
Wim Taymans
0c2b4df8e5
alsa: implement _delay to get smoother timestamps
...
Fixes #536
2021-01-09 10:50:39 +01:00
Wim Taymans
3f0cadfa00
alsa: use rate_match to read exactly what we need
...
Use the rate match from the resampler to get the exact amount
of samples we need to provide in this cycle.
2021-01-08 16:55:24 +01:00
Wim Taymans
55c5e48578
alsa: set offset to 0 for playback streams
2020-12-18 15:32:27 +01:00
Wim Taymans
b8300c663b
improve some errors
...
Silence some -ENOENT warnings, they can happen when the object we
are introspecting is destroyed
2020-11-29 16:22:50 +01:00
Oschowa
92c541ea03
pipewire-alsa: Make sure to always fill the pipewire buffers with
...
silence on process if there is not enough data.
This fixes noise with the retroarch alsa backend on pause, which doesn't
actually pause the device.
2020-11-01 19:28:38 +01:00
Oschowa
86acbabe8f
pipewire-alsa: implement pause
2020-11-01 19:04:37 +01:00
Oschowa
d960724dfc
pipewire-alsa: fix inconsistent formating (tabs vs. spaces)
2020-11-01 18:38:46 +01:00
Wim Taymans
e571c0bcb1
alsa: Use "PipeWire ALSA" as the node name
...
So that it is easier to know it is the PipeWire one.
2020-10-27 16:11:14 +01:00
Mersad Jelacic
9de98df1b7
pipewire-alsa: Use monotonic clock
...
Use monotonic clock instead of gettimeofday for timestamps.
2020-10-27 14:53:17 +00:00
Wim Taymans
3567efb7f8
alsa: allow setting playback/capture_node as node name
...
See !314
2020-10-24 15:53:48 +02:00