Commit graph

3795 commits

Author SHA1 Message Date
Wim Taymans
091b5497a3 acp: try to set a verb before probing pro-audio devices
Some UCM devices need to be configured with a verb before we can try probing
the pcms. Find the highest priority verb and set that.
2023-08-07 12:56:24 +02:00
Wim Taymans
71262da6d7 audioconvert: remove requirement for data_loop
We just need to get a timestamp so that we can do the rate limiting, we
don't need anything accurate from the data_loop.
2023-08-01 18:20:04 +02:00
Wim Taymans
536129343a audioconvert: rate limit the out-of-buffer logging
See #3384
2023-08-01 15:06:28 +02:00
Wim Taymans
35d932bc8b audioconvert: only dequeue a buffer when queued
Add an extra check to only dequeue a buffer when it's queued. This
should always be the case but let's check again to be safe.

See #3384
2023-08-01 15:04:31 +02:00
Wim Taymans
88f0dbd6fc v4l2: don't set inotify on /dev
Doing inotify on /dev is not a good idea because we will be woken up by
a lot of unrelated events.

There is a report of a performance regression on some IO benchmark
because of lock contention within the fsnotify subsystem due to this.

Instead, just watch for attribute changes on the /dev/videoX files
directly. We are only interested in attribute changes, udev should
notify us when the file is added or removed.
2023-07-31 13:16:17 +02:00
Wim Taymans
fd585baa88 alsa: don't change avail when unchanged
Only update the avail when we did a snd_pcm_forward(). Otherwise
we might think there is more available than there really is and we
might get xrun.

See #3395
2023-07-31 12:10:36 +02:00
Barnabás Pőcze
07c574160c spa: bluez: backend-hsphfpd: actually free endpoint
Previously, `endpoint_free()` did not free the `struct hsphfpd_endpoint`
object itself, only its contents. Fix that.
2023-07-30 21:42:49 +02:00
Barnabás Pőcze
486d759fa9 spa: bluez: backend-hsphfpd: remove unnecessary NULL checks
`free()` already does a NULL check; and there is no reason
to have those NULL checks inline.
2023-07-30 21:41:41 +02:00
Barnabás Pőcze
4083502e03 spa: bluez: use some more spa_auto* 2023-07-30 13:45:49 +02:00
Barnabás Pőcze
ca85872e83 spa: bluez: use spa_auto for DBusError 2023-07-30 13:45:49 +02:00
Barnabás Pőcze
b52d590936 spa: bluez: add send_with_reply() dbus helper
This function sends a DBusMessage on a DBusConnection
and sets the reply callback of the resulting DBusPendingCall,
as well as properly cancelling the pending call if anything fails.
2023-07-30 13:45:49 +02:00
Barnabás Pőcze
6e581deb91 spa: bluez: use spa_autoptr for DBusMessage 2023-07-30 13:45:49 +02:00
Sourav Das
c6c3259a08 spa: fixes for dereferencing pointer to incomplete type in __typeof__
before gcc 10 its not supporting pointer dereferencing in __typeof__.
    so made changes according to that. Fixes #3375

    clang also defines __GNUC__ and resolves '4' along with __clang__ which
    resolves '1'. On any version of clang, __GNUC__ and resolves '4'.
    anyway clang has this feature since version 3.
2023-07-30 10:31:19 +05:30
Wim Taymans
dd78f3d5f7 alsa: disable htimestamp by default
It seems there are drivers that don't return a good values and we end up
with a lot of delay or automatic disable of htimestamp when the values
look too off.
2023-07-26 10:32:53 +02:00
Wim Taymans
ad1a36a718 audioconvert: add option to disable volume updates
Add channelmix.lock-volumes. When set to true it will disable volume
updates until set back to false.

See #3361
2023-07-25 12:36:23 +02:00
Pauli Virtanen
cd3375f39e meson.build: enable LC3 by default
Enable LE Audio support by default if liblc3 is present, the Pipewire
implementation should be OK. Remove unused HAVE_BLUETOOTH_BAP define,
we don't have any #ifdefs for this.

The feature is still disabled by default in BlueZ, which also now takes
care of necessary hardware feature checks, and should be safe to enable
on Pipewire side.
2023-07-25 07:26:21 +00:00
Wim Taymans
8eb1d8f2ac dbus: add some more debug 2023-07-20 10:15:30 +02:00
Wim Taymans
ab1436fb3b audioconvert: improve EMPTY flag on output buffers
Only set the EMPTY flag on output buffers if we don't have any
previously queued samples and the input is EMPTY.

Fixes #3365
2023-07-19 21:39:25 +02:00
Wim Taymans
f99fd7d75a improve some debug 2023-07-19 21:39:12 +02:00
Robert Mader
5bac089229 spa: libcamera: add libcamera version check for properties::SystemDevices 2023-07-19 09:21:03 +00:00
Ashok Sidipotu
6cd29aed05 spa: v4l2: get the device number of the v4l2 device
This value can be used in filtering the camera devices in consultation with
libcamera
2023-07-19 09:21:03 +00:00
Ashok Sidipotu
79518d13ae spa: libcamera: consume the device numbers libcamera property
Pass on the device numbers property of libcamera to session managers, with they
are better equipped to filter the camera/video devices across v4l2 and libcamera.
2023-07-19 09:21:03 +00:00
Wim Taymans
983d34f344 spa: add some more docs
See #3351
2023-07-17 17:46:04 +02:00
Barnabás Pőcze
146665893e spa: bluez: upower: keep track of pending call
Keep track of the DBusPendingCall and cancel it when being destroyed,
furthermore, create `update_battery_percentage()` and don't duplicate code.
2023-07-15 01:08:24 +02:00
Barnabás Pőcze
708e5443ae spa: bluez: add steal_reply_and_unref() helper
This function retrieves the reply from a DBusPendingCall and unrefs the call.
2023-07-15 01:04:23 +02:00
Barnabás Pőcze
183270f53c spa: bluez: add cancel_and_unref() dbus helper
This function cancels and unrefs a DBusPendingCall and
resets the pointer to NULL.
2023-07-15 01:04:22 +02:00
Barnabás Pőcze
1025d5c600 spa: bluez: remove some unused DBusErrors 2023-07-15 00:55:31 +02:00
Barnabás Pőcze
10f1b6c13c spa: bluez: backend-hsphfpd: use const char * for string literal 2023-07-14 22:35:36 +02:00
Barnabás Pőcze
667703e27d spa: bluez: backend-native: remove unnecessary array of DBusMessageIter 2023-07-14 22:35:35 +02:00
Barnabás Pőcze
66014e5828 spa: bluez: backend-native: fix DTMF string leak 2023-07-14 18:20:07 +02:00
Barnabás Pőcze
33a5c4ba10 spa: bluez: fix spelling of HAVE_REALLOCARRAY feature macro
It should have two `R`s not three.
2023-07-14 18:20:07 +02:00
columbarius
0a13d37e5c spa: Add SPA_VIDEO_FLAG_MODIFIER_FIXATION_REQUIRED
This flags allows clients to use the parse_format functions and
determine from their result directly if the modifer was fixated yet.
2023-07-14 08:20:54 +00:00
Barnabás Pőcze
abe8c3581f spa: bluez: free spa_bt_transport::configuration
`spa_bt_transport_free()` did not free `spa_bt_transport::configuration`,
so fix that.
2023-07-13 21:27:53 +02:00
Wim Taymans
0501ef165a spa: add atomic.h and port macros to it 2023-07-13 12:25:22 +02:00
Wim Taymans
0cefb71c97 spa: fix compilation 2023-07-11 19:56:44 +02:00
Wim Taymans
dc07c2321b spa: add spa_ratelimit 2023-07-11 19:25:35 +02:00
Barnabás Pőcze
fe45786a5d treewide: add some examples for the spa_auto* macros 2023-07-11 14:23:53 +02:00
Barnabás Pőcze
65d949558b spa: utils: add scope based resource cleanup
systemd, dbus-broker, and many glib applications heavily
utilize the GNU C attribute "cleanup" to achieve C++ RAII-like
semantics for local resource management. This commit introduces
essentialy same mechanism into pipewire.

At the moment, this is inteded to be a strictly private API.

free() and close() as cleanup targets are sufficiently common
to warrant their own special macros:

  spa_autofree char *s = strdup(p);
  // will call `free(s)` at the end of the lifetime of `s`

  spa_autoclose int fd = openat(...);
  // will call `close(fd)` if `fd >= 0` at the end of the lifetime of `fd`

However, with `spa_auto()` or `spa_autoptr()` it is possible to define
other variables that will be cleaned up properly. Currently four are supported:

  spa_autoptr(FILE) f = fopen(...);
  // `f` has type `FILE *`
  // will call `fclose(f)` if `f != NULL`

  spa_autoptr(DIR) d = opendir(...);
  // `d` has type `DIR *`
  // will call `closedir(d)` if `d != NULL`

  spa_autoptr(pw_properties) p = pw_properties_new(NULL, NULL);
  // `p` has type `struct pw_properties *`
  // will call `pw_properties_free(p)`

  spa_auto(pw_strv) v = pw_split_strv(...);
  // `v` has type `char **`
  // will call `pw_strv_free(v)`

It is possible to add support for other types, e.g.

  SPA_DEFINE_AUTOPTR_CLEANUP(pw_main_loop, struct pw_main_loop, {
    // the pointer can be accessed using `*thing`
    // `thing` has type `struct pw_main_loop **`
    spa_clear_ptr(*thing, pw_main_loop_destroy);
  })

  spa_autoptr(pw_main_loop) l = ...;
  // `l` has type `struct pw_main_loop *`
  // will call `pw_main_loop_destroy(l)`

or

  SPA_DEFINE_AUTO_CLEANUP(spa_pod_dynamic_builder, struct spa_pod_dynamic_builder, {
    // `thing` has type `struct spa_pod_dynamic_builder *`
    spa_pod_dynamic_builder_clean(thing);
  })

  spa_auto(spa_pod_dynamic_builder) builder = ...
  // `builder` has type `struct spa_pod_dynamic_builder`
  // will call `spa_pod_dynamic_builder_clean(&builder)`

The first argument is always an arbitrary name. This name must be passed to
`spa_auto()` and `spa_autoptr()` as it is what determines the actual type
and destructor used. The second parameter is the concrete type. For
`SPA_DEFINE_AUTO_CLEANUP()` this is the concrete type to be used, while for
`SPA_DEFINE_AUTOPTR_CLEANUP()` it is the concrete type without the
outermost pointer. That is,

  SPA_DEFINE_AUTOPTR_CLEANUP(A, foo, ...)
  SPA_DEFINE_AUTO_CLEANUP(B, foo, ...)

  spa_autoptr(A) x; // `x` has type `foo *`
  spa_auto(B) y; // `y` has type `foo`

A couple other macros are also added:

  spa_clear_ptr(ptr, destructor)
  // calls `destructor(ptr)` if `ptr != NULL` and sets `ptr` to `NULL`

  spa_clear_fd(fd)
  // calls `close(fd)` if `fd >= 0` and sets `fd` to -1

  spa_steal_ptr(ptr)
  // sets `ptr` to `NULL` and returns the old value,
  // useful for preventing the auto cleanup mechanism from kicking in
  // when returning the pointer from a function

  spa_steal_fd(fd)
  // sets `fd` to -1 and returns the old value
2023-07-11 14:23:53 +02:00
Wim Taymans
baa5497617 spa: warn out of buffers
Running out of buffers is pretty bad and warrants a warning because it
can cause loss of audio.

See #3316
2023-07-07 12:11:02 +02:00
Wim Taymans
b5b01f4dd2 resample-peaks: improve peaks some more
Update the i_count in the loop because we use it to check when we have
completed a chunk.
2023-07-05 14:07:30 +02:00
Wim Taymans
48bf039e25 resample-peaks: fix peaks resampler
Avoid some segfaults in some cases.

fixes #3320
2023-07-05 13:46:08 +02:00
Wim Taymans
159fa7177a alsa: fix threshold sign
Be careful when converting the uint32_t to int64_t, first convert and
then flip the sign.
2023-07-05 12:01:08 +02:00
Wim Taymans
937a13d93f alsa: relax htimestamp threshold a little
Only assume an error when larger than 3 times the expected size. Clamp
to the threshold to not cause excessive delay compensation.
2023-07-05 11:46:19 +02:00
Wim Taymans
42a099381b v4l2: handle ENOTTY
Instead of erroring out, go to the next format when enumerating frame
size or frame interval.

See #3325
2023-07-04 11:36:37 +02:00
Barnabás Pőcze
8c17a6626d treewide: mark some functions static
These were found by enabling the "missing-declarations" warning.
2023-07-03 19:40:31 +02:00
Barnabás Pőcze
ab6ff1bcde spa: libcamera: use init list when calling generateConfiguration()
Pass an initializer list to `Camera::generateConfiguration()` instead
of constructing a vector and adding the single element "manually".
2023-07-03 19:40:31 +02:00
Barnabás Pőcze
6275269f09 spa: bluez: remove some unused variables 2023-07-03 19:40:31 +02:00
Barnabás Pőcze
f6ea5421e6 spa: bluez: do not open-code asprintf() 2023-07-03 19:40:31 +02:00
Barnabás Pőcze
605404c781 spa: bluez: device_stop_timer(): remove redundant decl
Also move the declaration of `media_codec_switch_free()`
up to the beginning of the file, near the other decls.
2023-07-03 19:40:31 +02:00
Barnabás Pőcze
0ed8880489 spa: bluez: modemmanager: do not use old style declaration 2023-07-03 19:40:31 +02:00