mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-17 08:56:49 -05:00
alsa-compress-offload: Add device object and udev based autodetection
As part of this, in alsa-udev.c, certain structures and variables referred to as "device" are renamed to "card". Otherwise, there is ambiguity, since "device" can mean a udev device, an SPA device, a compress-offload device, a PCM device etc. Also, replace "card id" with "card number" to emphasize that these integers are not actually SPA object IDs.
This commit is contained in:
parent
ae4bff78a3
commit
8e6d070148
8 changed files with 1050 additions and 237 deletions
36
spa/plugins/alsa/compress-offload-api-util.c
Normal file
36
spa/plugins/alsa/compress-offload-api-util.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include "compress-offload-api.h"
|
||||
#include "compress-offload-api-util.h"
|
||||
|
||||
int get_compress_offload_device_direction(int card_nr, int device_nr,
|
||||
struct spa_log *log,
|
||||
enum spa_compress_offload_direction *direction)
|
||||
{
|
||||
int ret = 0;
|
||||
struct compress_offload_api_context *device_context;
|
||||
const struct snd_compr_caps *compr_caps;
|
||||
|
||||
device_context = compress_offload_api_open(card_nr, device_nr, log);
|
||||
if (device_context == NULL)
|
||||
return -errno;
|
||||
|
||||
compr_caps = compress_offload_api_get_caps(device_context);
|
||||
|
||||
switch (compr_caps->direction) {
|
||||
case SND_COMPRESS_PLAYBACK:
|
||||
*direction = SPA_COMPRESS_OFFLOAD_DIRECTION_PLAYBACK;
|
||||
break;
|
||||
case SND_COMPRESS_CAPTURE:
|
||||
*direction = SPA_COMPRESS_OFFLOAD_DIRECTION_CAPTURE;
|
||||
break;
|
||||
default:
|
||||
spa_log_error(log, "card nr %d device nr %d: unknown direction %#" PRIx32,
|
||||
card_nr, device_nr, (uint32_t)(compr_caps->direction));
|
||||
ret = -EINVAL;
|
||||
}
|
||||
|
||||
compress_offload_api_close(device_context);
|
||||
|
||||
return ret;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue