PipeWire 1.4.1
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
device.h
Go to the documentation of this file.
1/* Simple Plugin API */
2/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef SPA_DEVICE_H
6#define SPA_DEVICE_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <spa/utils/defs.h>
13#include <spa/utils/hook.h>
14#include <spa/utils/dict.h>
15#include <spa/pod/event.h>
16
17#ifndef SPA_API_DEVICE
18 #ifdef SPA_API_IMPL
19 #define SPA_API_DEVICE SPA_API_IMPL
20 #else
21 #define SPA_API_DEVICE static inline
22 #endif
23#endif
24
38#define SPA_TYPE_INTERFACE_Device SPA_TYPE_INFO_INTERFACE_BASE "Device"
39
40#define SPA_VERSION_DEVICE 0
41struct spa_device { struct spa_interface iface; };
42
48struct spa_device_info {
49#define SPA_VERSION_DEVICE_INFO 0
50 uint32_t version;
51
52#define SPA_DEVICE_CHANGE_MASK_FLAGS (1u<<0)
53#define SPA_DEVICE_CHANGE_MASK_PROPS (1u<<1)
54#define SPA_DEVICE_CHANGE_MASK_PARAMS (1u<<2)
55 uint64_t change_mask;
56 uint64_t flags;
57 const struct spa_dict *props;
58 struct spa_param_info *params;
59 uint32_t n_params;
60};
61
62#define SPA_DEVICE_INFO_INIT() ((struct spa_device_info){ SPA_VERSION_DEVICE_INFO, })
70#define SPA_VERSION_DEVICE_OBJECT_INFO 0
71 uint32_t version;
73 const char *type;
74 const char *factory_name;
76#define SPA_DEVICE_OBJECT_CHANGE_MASK_FLAGS (1u<<0)
77#define SPA_DEVICE_OBJECT_CHANGE_MASK_PROPS (1u<<1)
78 uint64_t change_mask;
79 uint64_t flags;
80 const struct spa_dict *props;
81};
82
83#define SPA_DEVICE_OBJECT_INFO_INIT() ((struct spa_device_object_info){ SPA_VERSION_DEVICE_OBJECT_INFO, })
84
86#define SPA_RESULT_TYPE_DEVICE_PARAMS 1
88 uint32_t id;
89 uint32_t index;
90 uint32_t next;
91 struct spa_pod *param;
92};
93
94#define SPA_DEVICE_EVENT_INFO 0
95#define SPA_DEVICE_EVENT_RESULT 1
96#define SPA_DEVICE_EVENT_EVENT 2
97#define SPA_DEVICE_EVENT_OBJECT_INFO 3
98#define SPA_DEVICE_EVENT_NUM 4
99
107#define SPA_VERSION_DEVICE_EVENTS 0
108 uint32_t version;
111 void (*info) (void *data, const struct spa_device_info *info);
112
114 void (*result) (void *data, int seq, int res, uint32_t type, const void *result);
115
117 void (*event) (void *data, const struct spa_event *event);
121 void (*object_info) (void *data, uint32_t id,
123};
124
125#define SPA_DEVICE_METHOD_ADD_LISTENER 0
126#define SPA_DEVICE_METHOD_SYNC 1
127#define SPA_DEVICE_METHOD_ENUM_PARAMS 2
128#define SPA_DEVICE_METHOD_SET_PARAM 3
129#define SPA_DEVICE_METHOD_NUM 4
130
134struct spa_device_methods {
135 /* the version of the methods. This can be used to expand this
136 * structure in the future */
137#define SPA_VERSION_DEVICE_METHODS 0
138 uint32_t version;
155 int (*add_listener) (void *object,
156 struct spa_hook *listener,
157 const struct spa_device_events *events,
158 void *data);
174 int (*sync) (void *object, int seq);
175
201 int (*enum_params) (void *object, int seq,
202 uint32_t id, uint32_t index, uint32_t max,
203 const struct spa_pod *filter);
204
226 int (*set_param) (void *object,
227 uint32_t id, uint32_t flags,
228 const struct spa_pod *param);
229};
230
232 struct spa_hook *listener,
233 const struct spa_device_events *events,
234 void *data)
235{
236 return spa_api_method_r(int, -ENOTSUP, spa_device, &object->iface, add_listener, 0,
237 listener, events, data);
238
239}
240SPA_API_DEVICE int spa_device_sync(struct spa_device *object, int seq)
241{
242 return spa_api_method_r(int, -ENOTSUP, spa_device, &object->iface, sync, 0,
243 seq);
244}
246 uint32_t id, uint32_t index, uint32_t max,
247 const struct spa_pod *filter)
248{
249 return spa_api_method_r(int, -ENOTSUP, spa_device, &object->iface, enum_params, 0,
250 seq, id, index, max, filter);
251}
253 uint32_t id, uint32_t flags,
254 const struct spa_pod *param)
255{
256 return spa_api_method_r(int, -ENOTSUP, spa_device, &object->iface, set_param, 0,
257 id, flags, param);
258}
259
260#define SPA_KEY_DEVICE_ENUM_API "device.enum.api"
262#define SPA_KEY_DEVICE_API "device.api"
264#define SPA_KEY_DEVICE_NAME "device.name"
265#define SPA_KEY_DEVICE_ALIAS "device.alias"
266#define SPA_KEY_DEVICE_NICK "device.nick"
267#define SPA_KEY_DEVICE_DESCRIPTION "device.description"
268#define SPA_KEY_DEVICE_ICON "device.icon"
270#define SPA_KEY_DEVICE_ICON_NAME "device.icon-name"
272#define SPA_KEY_DEVICE_PLUGGED_USEC "device.plugged.usec"
274#define SPA_KEY_DEVICE_BUS_ID "device.bus-id"
275#define SPA_KEY_DEVICE_BUS_PATH "device.bus-path"
278#define SPA_KEY_DEVICE_BUS "device.bus"
281#define SPA_KEY_DEVICE_SUBSYSTEM "device.subsystem"
282#define SPA_KEY_DEVICE_SYSFS_PATH "device.sysfs.path"
284#define SPA_KEY_DEVICE_VENDOR_ID "device.vendor.id"
285#define SPA_KEY_DEVICE_VENDOR_NAME "device.vendor.name"
286#define SPA_KEY_DEVICE_PRODUCT_ID "device.product.id"
287#define SPA_KEY_DEVICE_PRODUCT_NAME "device.product.name"
288#define SPA_KEY_DEVICE_SERIAL "device.serial"
289#define SPA_KEY_DEVICE_CLASS "device.class"
290#define SPA_KEY_DEVICE_CAPABILITIES "device.capabilities"
291#define SPA_KEY_DEVICE_FORM_FACTOR "device.form-factor"
296#define SPA_KEY_DEVICE_PROFILE "device.profile"
297#define SPA_KEY_DEVICE_PROFILE_SET "device.profile-set"
298#define SPA_KEY_DEVICE_STRING "device.string"
300#define SPA_KEY_DEVICE_DEVIDS "device.devids"
306#ifdef __cplusplus
307} /* extern "C" */
308#endif
310#endif /* SPA_DEVICE_H */
spa/utils/defs.h
uint32_t int seq
Definition core.h:432
uint32_t id
Definition core.h:432
uint32_t int int res
Definition core.h:433
SPA_API_DEVICE int spa_device_sync(struct spa_device *object, int seq)
Definition device.h:271
SPA_API_DEVICE int spa_device_set_param(struct spa_device *object, uint32_t id, uint32_t flags, const struct spa_pod *param)
Definition device.h:283
SPA_API_DEVICE int spa_device_enum_params(struct spa_device *object, int seq, uint32_t id, uint32_t index, uint32_t max, const struct spa_pod *filter)
Definition device.h:276
SPA_API_DEVICE int spa_device_add_listener(struct spa_device *object, struct spa_hook *listener, const struct spa_device_events *events, void *data)
Definition device.h:262
#define spa_api_method_r(rtype, def, type, o, method, version,...)
Definition hook.h:291
spa/utils/hook.h
spa/pod/event.h
#define SPA_API_DEVICE
Definition device.h:28
spa_device_events:
Definition device.h:129
void(* result)(void *data, int seq, int res, uint32_t type, const void *result)
notify a result
Definition device.h:139
void(* event)(void *data, const struct spa_event *event)
a device event
Definition device.h:142
void(* info)(void *data, const struct spa_device_info *info)
notify extra information about the device
Definition device.h:136
uint32_t version
Definition device.h:133
Information about the device and parameters it supports.
Definition device.h:57
uint64_t flags
Definition device.h:69
struct spa_param_info * params
supported parameters
Definition device.h:71
uint32_t version
Definition device.h:60
uint32_t n_params
number of elements in params
Definition device.h:72
uint64_t change_mask
Definition device.h:68
spa_device_methods:
Definition device.h:164
uint32_t version
Definition device.h:169
int(* sync)(void *object, int seq)
Perform a sync operation.
Definition device.h:205
int(* enum_params)(void *object, int seq, uint32_t id, uint32_t index, uint32_t max, const struct spa_pod *filter)
Enumerate the parameters of a device.
Definition device.h:232
int(* set_param)(void *object, uint32_t id, uint32_t flags, const struct spa_pod *param)
Set the configurable parameter in device.
Definition device.h:257
int(* add_listener)(void *object, struct spa_hook *listener, const struct spa_device_events *events, void *data)
Set events to receive asynchronous notifications from the device.
Definition device.h:186
Information about a device object.
Definition device.h:83
uint32_t version
Definition device.h:86
const char * type
the object type managed by this device
Definition device.h:88
uint64_t change_mask
Definition device.h:95
const char * factory_name
a factory name that implements the object
Definition device.h:89
uint64_t flags
Definition device.h:96
Definition device.h:50
struct spa_interface iface
Definition device.h:50
Definition dict.h:51
Definition event.h:28
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:427
Definition hook.h:148
information about a parameter
Definition param.h:51
Definition pod.h:43
Definition device.h:106
uint32_t id
Definition device.h:107
uint32_t index
Definition device.h:108
uint32_t next
Definition device.h:109
struct spa_pod * param
Definition device.h:110
spa/utils/dict.h