Loading...
Searching...
No Matches
device.h
Go to the documentation of this file.
/* Simple Plugin API */
/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
/* SPDX-License-Identifier: MIT */
#ifndef SPA_DEVICE_H
#define SPA_DEVICE_H
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#include <spa/utils/dict.h>
#include <spa/pod/event.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SPA_API_DEVICE
#ifdef SPA_API_IMPL
#define SPA_API_DEVICE SPA_API_IMPL
#else
#define SPA_API_DEVICE static inline
#endif
#endif
#define SPA_TYPE_INTERFACE_Device SPA_TYPE_INFO_INTERFACE_BASE "Device"
#define SPA_VERSION_DEVICE 0
struct spa_device { struct spa_interface iface; };
struct spa_device_info {
#define SPA_VERSION_DEVICE_INFO 0
uint32_t version;
#define SPA_DEVICE_CHANGE_MASK_FLAGS (1u<<0)
#define SPA_DEVICE_CHANGE_MASK_PROPS (1u<<1)
#define SPA_DEVICE_CHANGE_MASK_PARAMS (1u<<2)
uint64_t change_mask;
uint64_t flags;
const struct spa_dict *props;
struct spa_param_info *params;
uint32_t n_params;
};
#define SPA_DEVICE_INFO_INIT() ((struct spa_device_info){ SPA_VERSION_DEVICE_INFO, })
struct spa_device_object_info {
#define SPA_VERSION_DEVICE_OBJECT_INFO 0
uint32_t version;
const char *type;
const char *factory_name;
#define SPA_DEVICE_OBJECT_CHANGE_MASK_FLAGS (1u<<0)
#define SPA_DEVICE_OBJECT_CHANGE_MASK_PROPS (1u<<1)
uint64_t change_mask;
uint64_t flags;
const struct spa_dict *props;
};
#define SPA_DEVICE_OBJECT_INFO_INIT() ((struct spa_device_object_info){ SPA_VERSION_DEVICE_OBJECT_INFO, })
#define SPA_RESULT_TYPE_DEVICE_PARAMS 1
struct spa_result_device_params {
uint32_t id;
uint32_t index;
uint32_t next;
struct spa_pod *param;
};
#define SPA_DEVICE_EVENT_INFO 0
#define SPA_DEVICE_EVENT_RESULT 1
#define SPA_DEVICE_EVENT_EVENT 2
#define SPA_DEVICE_EVENT_OBJECT_INFO 3
#define SPA_DEVICE_EVENT_NUM 4
struct spa_device_events {
/** version of the structure */
#define SPA_VERSION_DEVICE_EVENTS 0
uint32_t version;
void (*info) (void *data, const struct spa_device_info *info);
void (*result) (void *data, int seq, int res, uint32_t type, const void *result);
void (*event) (void *data, const struct spa_event *event);
void (*object_info) (void *data, uint32_t id,
const struct spa_device_object_info *info);
};
#define SPA_DEVICE_METHOD_ADD_LISTENER 0
#define SPA_DEVICE_METHOD_SYNC 1
#define SPA_DEVICE_METHOD_ENUM_PARAMS 2
#define SPA_DEVICE_METHOD_SET_PARAM 3
#define SPA_DEVICE_METHOD_NUM 4
struct spa_device_methods {
/* the version of the methods. This can be used to expand this
* structure in the future */
#define SPA_VERSION_DEVICE_METHODS 0
uint32_t version;
int (*add_listener) (void *object,
struct spa_hook *listener,
const struct spa_device_events *events,
void *data);
* asynchronously.
*
* Because all methods are serialized in the device, this can be used
* to wait for completion of all previous method calls.
*
* \param seq a sequence number
* \return 0 on success
* -EINVAL when node is NULL
* an async result
*/
int (*sync) (void *object, int seq);
int (*enum_params) (void *object, int seq,
uint32_t id, uint32_t index, uint32_t max,
const struct spa_pod *filter);
int (*set_param) (void *object,
uint32_t id, uint32_t flags,
const struct spa_pod *param);
};
SPA_API_DEVICE int spa_device_add_listener(struct spa_device *object,
struct spa_hook *listener,
const struct spa_device_events *events,
void *data)
{
return spa_api_method_r(int, -ENOTSUP, spa_device, &object->iface, add_listener, 0,
listener, events, data);
}
SPA_API_DEVICE int spa_device_sync(struct spa_device *object, int seq)
{
return spa_api_method_r(int, -ENOTSUP, spa_device, &object->iface, sync, 0,
seq);
}
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)
{
return spa_api_method_r(int, -ENOTSUP, spa_device, &object->iface, enum_params, 0,
seq, id, index, max, filter);
}
SPA_API_DEVICE int spa_device_set_param(struct spa_device *object,
uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
return spa_api_method_r(int, -ENOTSUP, spa_device, &object->iface, set_param, 0,
id, flags, param);
}
#define SPA_KEY_DEVICE_ENUM_API "device.enum.api"
#define SPA_KEY_DEVICE_API "device.api"
#define SPA_KEY_DEVICE_NAME "device.name"
#define SPA_KEY_DEVICE_ALIAS "device.alias"
#define SPA_KEY_DEVICE_NICK "device.nick"
#define SPA_KEY_DEVICE_DESCRIPTION "device.description"
#define SPA_KEY_DEVICE_ICON "device.icon"
#define SPA_KEY_DEVICE_ICON_NAME "device.icon-name"
* Ex. "sound-card-speakers-usb" */
#define SPA_KEY_DEVICE_PLUGGED_USEC "device.plugged.usec"
#define SPA_KEY_DEVICE_BUS_ID "device.bus-id"
#define SPA_KEY_DEVICE_BUS_PATH "device.bus-path"
* format.
* Ex. "pci-0000:00:14.0-usb-0:3.2:1.0" */
#define SPA_KEY_DEVICE_BUS "device.bus"
#define SPA_KEY_DEVICE_SUBSYSTEM "device.subsystem"
#define SPA_KEY_DEVICE_SYSFS_PATH "device.sysfs.path"
#define SPA_KEY_DEVICE_VENDOR_ID "device.vendor.id"
#define SPA_KEY_DEVICE_VENDOR_NAME "device.vendor.name"
#define SPA_KEY_DEVICE_PRODUCT_ID "device.product.id"
#define SPA_KEY_DEVICE_PRODUCT_NAME "device.product.name"
#define SPA_KEY_DEVICE_SERIAL "device.serial"
#define SPA_KEY_DEVICE_CLASS "device.class"
#define SPA_KEY_DEVICE_CAPABILITIES "device.capabilities"
#define SPA_KEY_DEVICE_FORM_FACTOR "device.form-factor"
#define SPA_KEY_DEVICE_PROFILE "device.profile"
#define SPA_KEY_DEVICE_PROFILE_SET "device.profile-set"
#define SPA_KEY_DEVICE_STRING "device.string"
#define SPA_KEY_DEVICE_DEVIDS "device.devids"
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SPA_DEVICE_H */
defs.h
spa/utils/defs.h
seq
uint32_t int seq
Definition core.h:432
id
uint32_t id
Definition core.h:432
res
uint32_t int int res
Definition core.h:433
spa_device_sync
SPA_API_DEVICE int spa_device_sync(struct spa_device *object, int seq)
Definition device.h:271
spa_device_set_param
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_device_enum_params
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_device_add_listener
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
spa_api_method_r
#define spa_api_method_r(rtype, def, type, o, method, version,...)
Definition hook.h:291
hook.h
spa/utils/hook.h
event.h
spa/pod/event.h
SPA_API_DEVICE
#define SPA_API_DEVICE
Definition device.h:28
spa_device_events
spa_device_events:
Definition device.h:129
spa_device_events::result
void(* result)(void *data, int seq, int res, uint32_t type, const void *result)
notify a result
Definition device.h:139
spa_device_events::event
void(* event)(void *data, const struct spa_event *event)
a device event
Definition device.h:142
spa_device_events::version
uint32_t version
Definition device.h:133
spa_device_info
Information about the device and parameters it supports.
Definition device.h:57
spa_device_info::flags
uint64_t flags
Definition device.h:69
spa_device_info::params
struct spa_param_info * params
supported parameters
Definition device.h:71
spa_device_info::version
uint32_t version
Definition device.h:60
spa_device_info::n_params
uint32_t n_params
number of elements in params
Definition device.h:72
spa_device_info::change_mask
uint64_t change_mask
Definition device.h:68
spa_device_methods
spa_device_methods:
Definition device.h:164
spa_device_methods::sync
int(* sync)(void *object, int seq)
Perform a sync operation.
Definition device.h:205
spa_device_methods::enum_params
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
spa_device_methods::set_param
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
spa_device_methods::add_listener
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
spa_device_object_info
Information about a device object.
Definition device.h:83
spa_device_object_info::type
const char * type
the object type managed by this device
Definition device.h:88
spa_device_object_info::change_mask
uint64_t change_mask
Definition device.h:95
spa_device_object_info::factory_name
const char * factory_name
a factory name that implements the object
Definition device.h:89
spa_device_object_info::flags
uint64_t flags
Definition device.h:96
spa_device
Definition device.h:50
spa_device::iface
struct spa_interface iface
Definition device.h:50
spa_dict
Definition dict.h:51
spa_event
Definition event.h:28
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:427
spa_interface
Definition hook.h:148
spa_param_info
information about a parameter
Definition param.h:56
spa_pod
Definition pod.h:57
spa_result_device_params
Definition device.h:106
spa_result_device_params::index
uint32_t index
Definition device.h:108
spa_result_device_params::next
uint32_t next
Definition device.h:109
dict.h
spa/utils/dict.h