Commit graph

3805 commits

Author SHA1 Message Date
Wim Taymans 07b8954dc8 v4l2: handle inotify errors
Handle inotify errors and remove the source.

See #3439
2023-08-21 16:27:00 +02:00
Ashok Sidipotu cd24fe2fe9 bluez5: A2DP and BAP profiles to enumerate only codec profiles
This avoids the potential confusion when both codecless and codec profiles are
enumerated for A2DP.
Give base name to highest priority profile, so that best codec can be selected
at command line with out knowing which codecs are actually supported.
2023-08-21 08:21:37 +00:00
Pauli Virtanen 8f6d266632 bluez5: reacquire transport always for playing for A2DP
Some A2DP devices don't like reusing the same transport for different
media-sink instances, possibly because encoder is reset in between and
there can be a gap in transmitted audio.

This doesn't matter for SCO/ISO.
2023-08-18 15:07:01 +00:00
Tom A. Wagner 7b40ca4f27 pod: Fix spa_pod_builder_control() return type
Fixes the return type of spa_pod_builder_control() from uint32_t to int.

Since the function returns the int returned by spa_pod_builder_raw,
the return type of the function should also be an int.
2023-08-09 12:59:09 +00:00
Wim Taymans f5d1d7e683 evl: fix timerfd read
It should read uint64_t now.

Tested: Jorge Ramirez-Ortiz <jorge@foundries.io>
2023-08-09 12:46:20 +02:00
Jorge Ramirez-Ortiz ea0e92c5d9 meson: change EVL include paths 2023-08-09 12:09:30 +02:00
Wim Taymans ba7af15cb2 evl: Use complete API to create xbufs
So that we can set nonblock directly.

Tested: Jorge Ramirez-Ortiz <jorge@foundries.io>
2023-08-09 12:06:24 +02:00
Arun Raghavan 86bd0eb708 logger: Add a mechanism to force colourised logging
This is handy if we want to redirect to a file but have colours to make
manual parsing easier (for example with `less -R`).
2023-08-08 17:13:31 +00:00
Jorge Ramirez-Ortiz 17cda59478 evl: update to Xenomai4 r46
Fix build issues.

Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
2023-08-08 19:09:39 +02:00
columbarius 6d59ad21c2 spa: set MANDATORY flag when building video format with modifier
Proper negotiation requires that formats with modifiers are not matched
with those without. This is ensured by using SPA_POD_PROP_FLAG_MANDATORY.
2023-08-08 07:00:11 +00:00
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